Last active
August 29, 2015 14:22
-
-
Save ItsSpyce/793a920242393cf35551 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (string.IsNullOrEmpty(newPassword)){ | |
validation.Add("Please choose a new password."); | |
} | |
else if (string.IsNullOrEmpty(confirmPassword)){ | |
validation.Add("Please confirm your password."); | |
} | |
else{ | |
// now we know that newPassword and confirmPassword have contents, lets check them. | |
if (newPassword != confirmPassword){ | |
validation.Add("Your new password and confirmed password do not match."); | |
} | |
// idk if you want to, but if you're checking password requirements, you want to here. | |
else if (!PasswordValidator.IsValid(newPassword)){ | |
validation.Add("Your password does not meet the requirements."); | |
} | |
else { | |
if (Hasher.HashPassword(oldPassword, Hash.Basic /*idk what you use*/) != target.PasswordHash){ | |
validation.Add("Your password is incorrect. We could not update your password.") | |
} | |
else{ | |
target.PasswordHash = Hasher.HashPassword(newPassword, Hash.Basic); | |
redisUser.UpdateUser(target); | |
return RedirectToAction("Profile"); | |
} | |
} | |
} | |
ViewData["validationSummary"] = validation.ToArray(); | |
return View(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment