public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
            switch (result)
            {
                case SignInStatus.Success:
                    return RedirectToLocal(returnUrl);
                case SignInStatus.LockedOut:
                    return View("Lockout");
                case SignInStatus.RequiresVerification:
                    return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
                case SignInStatus.Failure:
                default:
                    ModelState.AddModelError("", "Invalid login attempt.");
                    return View(model);
            }
        }
 public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
 {
     var custEmailConf = EmailConfirmation(model.LoginUsername);
     var custUserName = FindUserName(model.LoginUsername);
     var result = await SignInManager.PasswordSignInAsync(model.LoginUsername, model.LoginPassword, model.RememberMe, shouldLockout: false);
     if (custEmailConf == false && custUserName != null && result.ToString() == "Success")
     {
         AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
         EConfUser = model.LoginUsername;
         return RedirectToAction("EmailConfirmationFailed", "Account");
     }
     else
     {
         ViewBag.ReturnUrl = returnUrl;
         if (ModelState.IsValid)
         {
             switch (result)
             {
                 case SignInStatus.Success:
                     UpdateLastLoginDate(model.LoginUsername);
                     return RedirectToLocal(returnUrl);
                 case SignInStatus.LockedOut:
                     return View("Lockout");
                 case SignInStatus.RequiresVerification:
                     return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
                 case SignInStatus.Failure:
                 default:
                     ModelState.AddModelError("", "Invalid login attempt.");
                     return View("Login");
             }
         }
         // If we got this far, something failed, redisplay form
         return View("Login");
     }
 }