1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-08 06:28:14 -05:00

Fix premium check for emergency access (#1090)

This commit is contained in:
Oscar Hinton 2021-01-15 21:56:17 +01:00 committed by GitHub
parent 9b80d97c19
commit adbfd0e107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,7 @@ namespace Bit.Core.Services
private readonly IUserRepository _userRepository; private readonly IUserRepository _userRepository;
private readonly ICipherRepository _cipherRepository; private readonly ICipherRepository _cipherRepository;
private readonly IMailService _mailService; private readonly IMailService _mailService;
private readonly IUserService _userService;
private readonly IDataProtector _dataProtector; private readonly IDataProtector _dataProtector;
private readonly GlobalSettings _globalSettings; private readonly GlobalSettings _globalSettings;
private readonly IPasswordHasher<User> _passwordHasher; private readonly IPasswordHasher<User> _passwordHasher;
@ -29,6 +30,7 @@ namespace Bit.Core.Services
IUserRepository userRepository, IUserRepository userRepository,
ICipherRepository cipherRepository, ICipherRepository cipherRepository,
IMailService mailService, IMailService mailService,
IUserService userService,
IPasswordHasher<User> passwordHasher, IPasswordHasher<User> passwordHasher,
IDataProtectionProvider dataProtectionProvider, IDataProtectionProvider dataProtectionProvider,
GlobalSettings globalSettings) GlobalSettings globalSettings)
@ -37,6 +39,7 @@ namespace Bit.Core.Services
_userRepository = userRepository; _userRepository = userRepository;
_cipherRepository = cipherRepository; _cipherRepository = cipherRepository;
_mailService = mailService; _mailService = mailService;
_userService = userService;
_passwordHasher = passwordHasher; _passwordHasher = passwordHasher;
_dataProtector = dataProtectionProvider.CreateProtector("EmergencyAccessServiceDataProtector"); _dataProtector = dataProtectionProvider.CreateProtector("EmergencyAccessServiceDataProtector");
_globalSettings = globalSettings; _globalSettings = globalSettings;
@ -44,7 +47,7 @@ namespace Bit.Core.Services
public async Task<EmergencyAccess> InviteAsync(User invitingUser, string invitingUsersName, string email, EmergencyAccessType type, int waitTime) public async Task<EmergencyAccess> InviteAsync(User invitingUser, string invitingUsersName, string email, EmergencyAccessType type, int waitTime)
{ {
if (!invitingUser.Premium) if (! await _userService.CanAccessPremium(invitingUser))
{ {
throw new BadRequestException("Not a premium user."); throw new BadRequestException("Not a premium user.");
} }