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
            SignInStatus result = await IdentityRepository.SignInManager.PasswordSignInAsync(model.Username, model.Password, model.RememberMe, shouldLockout: false);

            return ValidateAndReturnProperView(result, returnUrl, model);
        }
 private ActionResult ValidateAndReturnProperView(SignInStatus result, string returnUrl, LoginViewModel model)
 {
     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);
     }
 }