[HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) { string viewName = String.Empty; try { var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false); if (result == SignInStatus.Success) { if (model.IsEnabled == 0) { AuthenticationManager.SignOut(); stavime. ModelState.AddModelError("", Resources.UnableToLoginText); } else { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", Resources.UnableToLoginText); } } catch { //ModelState.AddModelError("", Resources.UnableToLoginText); } return View(_ViewForLogin); }
public class LoginViewModel { //[Required] [Display(Name = "Email")] [EmailAddress] public string Email { get; set; } [Required] [Display(Name = "User Name")] [EmailAddress] public string UserName { get; set; } [Required] [DataType(DataType.Password)] [Display(Name = "Password")] public string Password { get; set; } [Display(Name = "Rembember Me")] public bool RememberMe { get; set; } [Display(Name = "IsEnabled")] public int IsEnabled { get; set; } }