Beispiel #1
0
                public async Task<ActionResult> Login(LoginModel 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, false, 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 = false});
                        case SignInStatus.Failure:
                        default:
                            ModelState.AddModelError("", "Invalid login attempt.");
                            return View("Login", "~/Views/Shared/_LayoutBlank.cshtml", model);
                    }
                }
Beispiel #2
0
 public AccountInfoModel login(LoginModel model)
 {
     AccountInfoModel accountInfoModel = new AccountInfoModel();
     AccountInfoModel result;
     try
     {
         Account account = this.db.Accounts.Single((Account a) => a.Email == model.Email && a.Password == model.Password);
         if (account.AccountId > 0)
         {
             accountInfoModel.account = account;
         }
         else
         {
             accountInfoModel.account = new Account
             {
                 AccountId = -1
             };
         }
         result = accountInfoModel;
     }
     catch (Exception ex)
     {
         Console.Write(ex.Message);
         accountInfoModel.account = new Account
         {
             AccountId = -1
         };
         result = accountInfoModel;
     }
     return result;
 }