Fix firing of locked out event

This commit is contained in:
Sebastiaan Janssen
2017-06-04 14:33:13 +02:00
parent 0d80bf6a84
commit 1634789641
2 changed files with 18 additions and 7 deletions

View File

@@ -238,15 +238,21 @@ namespace Umbraco.Core.Security
/// </summary>
public IBackOfficeUserPasswordChecker BackOfficeUserPasswordChecker { get; set; }
public override Task<IdentityResult> SetLockoutEnabledAsync(int userId, bool enabled)
public override Task<IdentityResult> SetLockoutEndDateAsync(int userId, DateTimeOffset lockoutEnd)
{
var result = base.SetLockoutEnabledAsync(userId, enabled);
var result = base.SetLockoutEndDateAsync(userId, lockoutEnd);
if (result.Result.Succeeded)
// The way we unlock is by setting the lockoutEnd date to the current datetime
if (result.Result.Succeeded && lockoutEnd >= DateTimeOffset.UtcNow)
OnAccountLocked(new IdentityAuditEventArgs(AuditEvent.AccountLocked)
{
AffectedUser = userId
});
else
OnAccountUnlocked(new IdentityAuditEventArgs(AuditEvent.AccountUnlocked)
{
AffectedUser = userId
});
return result;
}
@@ -414,7 +420,7 @@ namespace Umbraco.Core.Security
ApplicationContext.Current.Services.UserService.Save(user);
OnAccounthUnlocked(new IdentityAuditEventArgs(AuditEvent.AccountUnlocked)
OnAccountUnlocked(new IdentityAuditEventArgs(AuditEvent.AccountUnlocked)
{
AffectedUser = user.Id
});
@@ -444,7 +450,7 @@ namespace Umbraco.Core.Security
if (AccountLocked != null) AccountLocked(this, e);
}
protected virtual void OnAccounthUnlocked(IdentityAuditEventArgs e)
protected virtual void OnAccountUnlocked(IdentityAuditEventArgs e)
{
if (AccountUnlocked != null) AccountUnlocked(this, e);
}