Example #1
0
 private bool CheckPasswordsSame(PickPasswordModel model)
 {
     if (model.Password.Equals(model.PasswordVerification, StringComparison.Ordinal))
     {
         return(true);
     }
     ModelState.AddModelError("Password", "Password and Verification must be the same");
     return(false);
 }
Example #2
0
        private async Task <ApplicationUser?> LoadUser(PickPasswordModel model)
        {
            var user = await userManager.FindByNameAsync(model.User);

            if (user == null)
            {
                ModelState.AddModelError("User", "User not found");
            }
            return(user);
        }
Example #3
0
 public async Task <ActionResult> Reset(PickPasswordModel model)
 {
     if (ModelState.IsValid && CheckPasswordsSame(model) && await LoadUser(model) is {} user)
     {
         return(ModelState.CheckResult(
                    await userManager.ResetPasswordAsync(user, model.PermissionHash, model.Password)) ?
                View("PasswordReset") : View(model));
     }
     return(View(model));
 }