public async Task <IActionResult> SetPasswordAsync(SetClientPasswordViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var user = await _userManager.FindByEmailAsync(model.Email); if (user == null) { // Don't reveal that the user does not exist return(RedirectToAction(nameof(SetPasswordConfirmation))); } var result = await _userManager.ResetPasswordAsync(user, model.Code, model.Password); if (result.Succeeded) { var client = _clientRepository.GetClientByUserId(user.Id); client.Status = 'A'; _clientRepository.Update(client); return(RedirectToAction(nameof(SetPasswordConfirmation))); } AddErrors(result); return(View()); }
public async Task <IActionResult> SetPasswordAsync(string userId, string code = null) { if (code == null) { throw new ApplicationException("A code must be supplied for password reset."); } var user = await _userManager.FindByIdAsync(userId); user.EmailConfirmed = true; await _userManager.UpdateAsync(user); var model = new SetClientPasswordViewModel { Email = user.Email, Code = code }; return(View(model)); }