public async Task <IActionResult> SetPassword(SetPasswordViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var user = await userManager.FindByIdAsync(HttpContext.User.GetUserId()); if (user != null) { var result = await userManager.AddPasswordAsync(user, model.NewPassword); if (result.Succeeded) { await signInManager.SignInAsync(user, isPersistent : false); this.AlertSuccess("your password has been set"); return(RedirectToAction("Index")); } else { this.AlertDanger("oops something went wrong please try again"); } AddErrors(result); } return(View(model)); }