1
0
mirror of https://github.com/bitwarden/server synced 2025-12-14 15:23:42 +00:00

cipher events

This commit is contained in:
Kyle Spearrin
2017-12-01 14:06:16 -05:00
parent 0662fc2163
commit a8fefb54c4
11 changed files with 86 additions and 36 deletions

View File

@@ -90,8 +90,7 @@ namespace Bit.Core.Services
public Guid? GetProperUserId(ClaimsPrincipal principal)
{
Guid userIdGuid;
if(!Guid.TryParse(GetUserId(principal), out userIdGuid))
if(!Guid.TryParse(GetUserId(principal), out var userIdGuid))
{
return null;
}
@@ -107,8 +106,7 @@ namespace Bit.Core.Services
return _currentContext.User;
}
Guid userIdGuid;
if(!Guid.TryParse(userId, out userIdGuid))
if(!Guid.TryParse(userId, out var userIdGuid))
{
return null;
}
@@ -425,7 +423,7 @@ namespace Bit.Core.Services
user.Key = key;
await _userRepository.ReplaceAsync(user);
await _eventService.LogUserEventAsync(user.Id, _currentContext, EventType.User_ChangedPassword);
await _eventService.LogUserEventAsync(user.Id, EventType.User_ChangedPassword);
return IdentityResult.Success;
}
@@ -503,7 +501,7 @@ namespace Bit.Core.Services
user.TwoFactorRecoveryCode = CoreHelpers.SecureRandomString(32, upper: false, special: false);
}
await SaveUserAsync(user);
await _eventService.LogUserEventAsync(user.Id, _currentContext, EventType.User_Enabled2fa);
await _eventService.LogUserEventAsync(user.Id, EventType.User_Enabled2fa);
}
public async Task DisableTwoFactorProviderAsync(User user, TwoFactorProviderType type)
@@ -517,7 +515,7 @@ namespace Bit.Core.Services
providers.Remove(type);
user.SetTwoFactorProviders(providers);
await SaveUserAsync(user);
await _eventService.LogUserEventAsync(user.Id, _currentContext, EventType.User_Disabled2fa);
await _eventService.LogUserEventAsync(user.Id, EventType.User_Disabled2fa);
}
public async Task<bool> RecoverTwoFactorAsync(string email, string masterPassword, string recoveryCode)
@@ -542,7 +540,7 @@ namespace Bit.Core.Services
user.TwoFactorProviders = null;
user.TwoFactorRecoveryCode = CoreHelpers.SecureRandomString(32, upper: false, special: false);
await SaveUserAsync(user);
await _eventService.LogUserEventAsync(user.Id, _currentContext, EventType.User_Recovered2fa);
await _eventService.LogUserEventAsync(user.Id, EventType.User_Recovered2fa);
return true;
}