Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. public ActionResult Login()
  2.         {
  3.             if (Session["KlientId"] != null)
  4.                 return RedirectToAction("LoggedIn", "Klient");
  5.             return View();
  6.         }
  7.  
  8. [HttpPost]
  9.         public ActionResult Login(Klient klient)
  10.         {
  11.             var user = db.Klienci.FirstOrDefault(k => k.Login == klient.Login && k.Password == klient.Password);
  12.  
  13.             if (user != null)
  14.             {
  15.                 TempData["KlientId"] = user.KlientId;
  16.                 Session["KlientId"] = user.KlientId;
  17.                 Session["Login"] = user.Login;
  18.                 Session.Timeout = 20;
  19.                 return Redirect("LoggedIn");
  20.                
  21.             }
  22.             else
  23.             {
  24.                 ModelState.AddModelError("", "Login lub hasło jest nieprawidłowe.");
  25.             }
  26.  
  27.             return View();
  28.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement