1
0
mirror of https://github.com/bitwarden/server synced 2026-01-06 18:43:36 +00:00

Added account delete.

This commit is contained in:
Kyle Spearrin
2015-12-27 00:14:56 -05:00
parent 8d7178bc74
commit 55be0c739e
8 changed files with 166 additions and 10 deletions

View File

@@ -18,10 +18,14 @@ namespace Bit.Core.Identity
IUserSecurityStampStore<User>
{
private readonly IUserRepository _userRepository;
private readonly CurrentContext _currentContext;
public UserStore(IUserRepository userRepository)
public UserStore(
IUserRepository userRepository,
CurrentContext currentContext)
{
_userRepository = userRepository;
_currentContext = currentContext;
}
public void Dispose() { }
@@ -40,16 +44,31 @@ namespace Bit.Core.Identity
public async Task<User> FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken = default(CancellationToken))
{
if(_currentContext?.User != null && _currentContext.User.Email == normalizedEmail)
{
return _currentContext.User;
}
return await _userRepository.GetByEmailAsync(normalizedEmail);
}
public async Task<User> FindByIdAsync(string userId, CancellationToken cancellationToken = default(CancellationToken))
{
if(_currentContext?.User != null && _currentContext.User.Id == userId)
{
return _currentContext.User;
}
return await _userRepository.GetByIdAsync(userId);
}
public async Task<User> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken = default(CancellationToken))
{
if(_currentContext?.User != null && _currentContext.User.Email == normalizedUserName)
{
return _currentContext.User;
}
return await _userRepository.GetByEmailAsync(normalizedUserName);
}