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 HibpBreachApiKey { get; set; }
|
||||
public virtual bool DisableUserRegistration { get; set; }
|
||||
public virtual bool DisableNewDeviceEmails { get; set; }
|
||||
public virtual InstallationSettings Installation { get; set; } = new InstallationSettings();
|
||||
public virtual BaseServiceUriSettings BaseServiceUri { get; set; } = new BaseServiceUriSettings();
|
||||
public virtual SqlSettings SqlServer { get; set; } = new SqlSettings();
|
||||
|
@ -33,6 +33,7 @@ namespace Bit.Core.IdentityServer
|
||||
private readonly IApplicationCacheService _applicationCacheService;
|
||||
private readonly IMailService _mailService;
|
||||
private readonly CurrentContext _currentContext;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
|
||||
public ResourceOwnerPasswordValidator(
|
||||
UserManager<User> userManager,
|
||||
@ -45,7 +46,8 @@ namespace Bit.Core.IdentityServer
|
||||
IOrganizationUserRepository organizationUserRepository,
|
||||
IApplicationCacheService applicationCacheService,
|
||||
IMailService mailService,
|
||||
CurrentContext currentContext)
|
||||
CurrentContext currentContext,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_deviceRepository = deviceRepository;
|
||||
@ -58,6 +60,7 @@ namespace Bit.Core.IdentityServer
|
||||
_applicationCacheService = applicationCacheService;
|
||||
_mailService = mailService;
|
||||
_currentContext = currentContext;
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
public async Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
|
||||
@ -384,9 +387,12 @@ namespace Bit.Core.IdentityServer
|
||||
{
|
||||
var deviceType = device.Type.GetType().GetMember(device.Type.ToString())
|
||||
.FirstOrDefault()?.GetCustomAttribute<DisplayAttribute>()?.GetName();
|
||||
if(!_globalSettings.DisableNewDeviceEmails)
|
||||
{
|
||||
await _mailService.SendNewDeviceLoggedInEmail(user.Email, deviceType, now,
|
||||
_currentContext.IpAddress);
|
||||
}
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user