Skip to content

Instantly share code, notes, and snippets.

@ItsSpyce
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ItsSpyce/793a920242393cf35551 to your computer and use it in GitHub Desktop.
Save ItsSpyce/793a920242393cf35551 to your computer and use it in GitHub Desktop.
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