public async Task <OperationResult> ChangeForgotPassword(ChangeForgotPasswordVM changeForgotPasswordVM) { var result = await _userRepository.UpdateForgotPassword(changeForgotPasswordVM); if (result.Succeeded) { await _context.SaveChangesAsync(); return(OperationResult.Success); } else { return(OperationResult.InvalidPassword); } }
public async Task <IdentityResult> UpdateForgotPassword(ChangeForgotPasswordVM changeForgotPasswordVM) { ApplicationUser user = await _userManager.FindByEmailAsync(changeForgotPasswordVM.Email); IdentityResult result = IdentityResult.Failed(); if (user != null) { var _passwordValidator = _httpContext.RequestServices.GetService(typeof(IPasswordValidator <ApplicationUser>)) as IPasswordValidator <ApplicationUser>; var _passwordHasher = _httpContext.RequestServices.GetService(typeof(IPasswordHasher <ApplicationUser>)) as IPasswordHasher <ApplicationUser>; result = await _passwordValidator.ValidateAsync(_userManager, user, changeForgotPasswordVM.NewPassword); if (result.Succeeded) { user.PasswordHash = _passwordHasher.HashPassword(user, changeForgotPasswordVM.NewPassword); await _userManager.UpdateAsync(user); await _context.SaveChangesAsync(); } } return(result); }
public async Task <OperationResult> ChangeForgotPassword(ChangeForgotPasswordVM changeForgotPasswordVM) { await _userStorage.ChangeForgotPassword(changeForgotPasswordVM); return(OperationResult.Success); }
public async Task <OperationResult> ChangeForgotPassword([FromBody] ChangeForgotPasswordVM сhangeForgotPasswordVM) { var result = await _userBuilder.ChangeForgotPassword(сhangeForgotPasswordVM); return(result); }