// // GET+POST: /User/Login public ActionResult Login() { CMS_Login login = new CMS_Login(); if (login.hasIdentity()) { _messages.addMessage("You are already logged in."); return RedirectToAction("Index", "Home"); } Form_LoginForm form = new Form_LoginForm(); if (Request.HttpMethod.ToLower() == form.getMethod().ToString()) { if (form.isValid(Request.Form)) { user user; if (login.checkCredentials(form["username"].getValue(), form["password"].getValue(), out user)) { login.SignIn(user); return RedirectToAction("Index", "Home"); } _messages.addError("Bad login or password"); } } string html = form.render(); ViewData["form"] = html; return View(); }
// // GET+POST: /User/Login public ActionResult Login() { CMS_Login login = new CMS_Login(); if (login.hasIdentity()) { _messages.addMessage("Ji� jste p�ihl�en(a)."); return RedirectToAction("Index", "Backend"); } Form_LoginForm form = new Form_LoginForm((Request.Params.AllKeys.Contains("backUrl") ? Request.Params["backUrl"] : "")); if (Request.HttpMethod.ToLower() == form.getMethod().ToString()) { if (form.isValid(Request.Form)) { user user; if (login.checkCredentials(form["username"].getValue(), form["password"].getValue(), out user)) { login.SignIn(user); if (Request.Params.AllKeys.Contains("backUrl") && !String.IsNullOrEmpty(Request.Params["backUrl"])) { return Redirect(Request.Params["backUrl"]); } return RedirectToAction("Index", "Backend"); } _messages.addError("�patn� u�ivatelsk� jm�no nebo heslo."); } } string html = form.render(); ViewData["form"] = html; return View(); }