public async Task <bool> Handle(UserAccountPasswordResetCommand request, CancellationToken cancellationToken) { var user = await _userManager.FindByEmailAsync(request.Email.Trim()); if (user == null) { throw new ApplicationException("User not found with that email Id"); } var result = await _userManager.ResetPasswordAsync(user, request.Code, request.NewPassword); if (result.Succeeded) { await NotificationEvent <AccountPasswordResetNotification> .Raise(_endpoint, new AccountPasswordResetNotification()); } return(result.Succeeded); }
public async Task <bool> Handle(GenerateUserAccountPasswordResetTokenCommand request, CancellationToken cancellationToken) { var user = await _userManager.FindByEmailAsync(request.Email.Trim()); if (user == null) { throw new ApplicationException("User not found with that email Id"); } var token = await _userManager.GeneratePasswordResetTokenAsync(user); await NotificationEvent <GeneratePasswordResetTokenNotification> .Raise(_endpoint, new GeneratePasswordResetTokenNotification() { Title = "Password recovery", Message = "Your password recovery token:", Token = token, Email = request.Email }); return(true); }
public async Task <bool> Handle(ChangeUserAccountPasswordCommand request, CancellationToken cancellationToken) { var user = await _userManager.FindByEmailAsync(request.Email.Trim()); if (user == null) { throw new ApplicationException("User not found with that email Id"); } var result = await _userManager.ChangePasswordAsync(user, request.CurrentPassword, request.NewPassword); if (result.Succeeded) { await NotificationEvent <ChangePasswordNotification> .Raise(_endpoint, new ChangePasswordNotification() { Title = "Account password change confirmation", Message = "Account password has changed successfully", Email = request.Email }); } return(result.Succeeded); }