Example #1
0
        public async Task <ActionResult> Logowanie(LogowanieViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var rezultat = await LogowanieZarzadzanie.PasswordSignInAsync(model.Login, model.Haslo, model.ZapamietajMnie, shouldLockout : false);

            if (rezultat == SignInStatus.Success)
            {
                var uzytkownik = dbContext.Users.FirstOrDefault(x => x.UserName == model.Login);
                if (UzytkownikZarzadzanie.IsEmailConfirmedAsync(uzytkownik.Id).Result == false)
                {
                    rezultat = SignInStatus.LockedOut;
                    AutoryzacjaZarzadzanie.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                }
            }
            switch (rezultat)
            {
            case SignInStatus.Success:
                return(RedirectToLocal(returnUrl));

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("WyslijKod", new { ReturnUrl = returnUrl, ZapamietajMnie = model.ZapamietajMnie }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login Attempt.");
                return(View(model));
            }
        }
Example #2
0
 public ActionResult Wyloguj()
 {
     AutoryzacjaZarzadzanie.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
     if (Session["koszyk"] != null)
     {
         Session["koszyk"] = null;
     }
     return(RedirectToAction("Index", "Home"));
 }