diff --git a/src/Umbraco.Core/Auditing/IdentityAuditEventArgs.cs b/src/Umbraco.Core/Auditing/IdentityAuditEventArgs.cs index 12b082129e..745bf4e692 100644 --- a/src/Umbraco.Core/Auditing/IdentityAuditEventArgs.cs +++ b/src/Umbraco.Core/Auditing/IdentityAuditEventArgs.cs @@ -56,6 +56,8 @@ namespace Umbraco.Core.Auditing { AccountLocked, AccountUnlocked, + ForgotPasswordRequested, + ForgotPasswordChangedSuccess, LoginFailed, LoginRequiresVerification, LoginSucces, diff --git a/src/Umbraco.Core/Security/BackOfficeUserManager.cs b/src/Umbraco.Core/Security/BackOfficeUserManager.cs index 88da52bb52..5e691257be 100644 --- a/src/Umbraco.Core/Security/BackOfficeUserManager.cs +++ b/src/Umbraco.Core/Security/BackOfficeUserManager.cs @@ -370,6 +370,22 @@ namespace Umbraco.Core.Security }); } + internal void RaiseForgotPasswordRequestedEvent(int userId) + { + OnForgotPasswordRequested(new IdentityAuditEventArgs(AuditEvent.ForgotPasswordRequested) + { + AffectedUser = userId + }); + } + + internal void RaiseForgotPasswordChangedSuccessEvent(int userId) + { + OnForgotPasswordChangedSuccess(new IdentityAuditEventArgs(AuditEvent.ForgotPasswordChangedSuccess) + { + AffectedUser = userId + }); + } + /// /// Clears a lock so that the membership user can be validated. /// @@ -404,6 +420,8 @@ namespace Umbraco.Core.Security public static event EventHandler AccountLocked; public static event EventHandler AccountUnlocked; + public static event EventHandler ForgotPasswordRequested; + public static event EventHandler ForgotPasswordChangedSuccess; public static event EventHandler LoginFailed; public static event EventHandler LoginRequiresVerification; public static event EventHandler LoginSuccess; @@ -422,6 +440,16 @@ namespace Umbraco.Core.Security if (AccountUnlocked != null) AccountUnlocked(this, e); } + protected virtual void OnForgotPasswordRequested(IdentityAuditEventArgs e) + { + if (ForgotPasswordRequested != null) ForgotPasswordRequested(this, e); + } + + protected virtual void OnForgotPasswordChangedSuccess(IdentityAuditEventArgs e) + { + if (ForgotPasswordChangedSuccess != null) ForgotPasswordChangedSuccess(this, e); + } + protected virtual void OnLoginFailed(IdentityAuditEventArgs e) { if (LoginFailed != null) LoginFailed(this, e); diff --git a/src/Umbraco.Web/Editors/AuthenticationController.cs b/src/Umbraco.Web/Editors/AuthenticationController.cs index 52ec819ec2..e49b566ebb 100644 --- a/src/Umbraco.Web/Editors/AuthenticationController.cs +++ b/src/Umbraco.Web/Editors/AuthenticationController.cs @@ -225,7 +225,9 @@ namespace Umbraco.Web.Editors Services.TextService.Localize("login/resetPasswordEmailCopySubject", //Ensure the culture of the found user is used for the email! UserExtensions.GetUserCulture(identityUser.Culture, Services.TextService)), - message); + message); + + _userManager.RaiseForgotPasswordRequestedEvent(user.Id); } } @@ -332,7 +334,8 @@ namespace Umbraco.Web.Editors () => model.UserId, () => unlockResult.Errors.First()); } } - + + _userManager.RaiseForgotPasswordChangedSuccessEvent(model.UserId); return Request.CreateResponse(HttpStatusCode.OK); } return Request.CreateValidationErrorResponse(