You're getting validation errors because the user isn't entering every single field from the
Users
class when they log in. They're only entering their email and password. The other required fields will be blank.
Create a view-model for the login action:
public class LoginViewModel
{
[Required]
[DataType(DataType.EmailAddress)]
[Display(Name = "Email Address")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginViewModel user)
{
...
}
HOWEVER, as I mentioned in the comments, you should
NEVER store passwords in plain text. Only ever store a salted hash of the password, using a unique salt for each record.
Secure Password Authentication Explained Simply[
^]
Salted Password Hashing - Doing it Right[
^]
And why are you re-inventing the wheel? ASP.NET has several perfectly good authentication systems built-in - for example,
ASP.NET Identity[
^].