mirror of
https://github.com/bitwarden/server.git
synced 2025-04-07 14:08:13 -05:00
disable new device emails env variable.
This commit is contained in:
parent
0885264800
commit
6c86996ab3
@ -14,6 +14,7 @@ namespace Bit.Core
|
|||||||
public virtual string InternalIdentityKey { get; set; }
|
public virtual string InternalIdentityKey { get; set; }
|
||||||
public virtual string HibpBreachApiKey { get; set; }
|
public virtual string HibpBreachApiKey { get; set; }
|
||||||
public virtual bool DisableUserRegistration { get; set; }
|
public virtual bool DisableUserRegistration { get; set; }
|
||||||
|
public virtual bool DisableNewDeviceEmails { get; set; }
|
||||||
public virtual InstallationSettings Installation { get; set; } = new InstallationSettings();
|
public virtual InstallationSettings Installation { get; set; } = new InstallationSettings();
|
||||||
public virtual BaseServiceUriSettings BaseServiceUri { get; set; } = new BaseServiceUriSettings();
|
public virtual BaseServiceUriSettings BaseServiceUri { get; set; } = new BaseServiceUriSettings();
|
||||||
public virtual SqlSettings SqlServer { get; set; } = new SqlSettings();
|
public virtual SqlSettings SqlServer { get; set; } = new SqlSettings();
|
||||||
|
@ -33,6 +33,7 @@ namespace Bit.Core.IdentityServer
|
|||||||
private readonly IApplicationCacheService _applicationCacheService;
|
private readonly IApplicationCacheService _applicationCacheService;
|
||||||
private readonly IMailService _mailService;
|
private readonly IMailService _mailService;
|
||||||
private readonly CurrentContext _currentContext;
|
private readonly CurrentContext _currentContext;
|
||||||
|
private readonly GlobalSettings _globalSettings;
|
||||||
|
|
||||||
public ResourceOwnerPasswordValidator(
|
public ResourceOwnerPasswordValidator(
|
||||||
UserManager<User> userManager,
|
UserManager<User> userManager,
|
||||||
@ -45,7 +46,8 @@ namespace Bit.Core.IdentityServer
|
|||||||
IOrganizationUserRepository organizationUserRepository,
|
IOrganizationUserRepository organizationUserRepository,
|
||||||
IApplicationCacheService applicationCacheService,
|
IApplicationCacheService applicationCacheService,
|
||||||
IMailService mailService,
|
IMailService mailService,
|
||||||
CurrentContext currentContext)
|
CurrentContext currentContext,
|
||||||
|
GlobalSettings globalSettings)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_deviceRepository = deviceRepository;
|
_deviceRepository = deviceRepository;
|
||||||
@ -58,6 +60,7 @@ namespace Bit.Core.IdentityServer
|
|||||||
_applicationCacheService = applicationCacheService;
|
_applicationCacheService = applicationCacheService;
|
||||||
_mailService = mailService;
|
_mailService = mailService;
|
||||||
_currentContext = currentContext;
|
_currentContext = currentContext;
|
||||||
|
_globalSettings = globalSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
|
public async Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
|
||||||
@ -384,8 +387,11 @@ namespace Bit.Core.IdentityServer
|
|||||||
{
|
{
|
||||||
var deviceType = device.Type.GetType().GetMember(device.Type.ToString())
|
var deviceType = device.Type.GetType().GetMember(device.Type.ToString())
|
||||||
.FirstOrDefault()?.GetCustomAttribute<DisplayAttribute>()?.GetName();
|
.FirstOrDefault()?.GetCustomAttribute<DisplayAttribute>()?.GetName();
|
||||||
await _mailService.SendNewDeviceLoggedInEmail(user.Email, deviceType, now,
|
if(!_globalSettings.DisableNewDeviceEmails)
|
||||||
_currentContext.IpAddress);
|
{
|
||||||
|
await _mailService.SendNewDeviceLoggedInEmail(user.Email, deviceType, now,
|
||||||
|
_currentContext.IpAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return device;
|
return device;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user