I want to use this model when user types in a password, it checks to see if the entered value is equal to a field corresponding to a particular column in the user database.
Here is my view model for resetting a password:
public class ResetPasswordViewModel
{
[Required]
[EmailAddress]
[Display(Name = "Email")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 15)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
public string Code { get; set; }
}
I want to add it in right under StringLength, but I am want to check using string equals or something similar. I am new to C#. My first instinct is to do this logic in the controller, but since they checked the length in this example it leads me to assume that I might be able to do it here.
This is just the stock example that comes with visual studio that uses the identity class for users.
Also, I am not sure which is the best way to accomplish this. Should I try to retrieve the un-hashed password and compare the actual string or should I hash the new (potential) password and then compare the hashed string?