public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } // If we got this far, something failed, redisplay form return View(model); }
public PartialViewResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (Membership.ValidateUser(model.Phone, model.Password)) { FormsAuthentication.SetAuthCookie(model.Phone, model.RememberMe); Client user = Manager.GetClientByPhone(model.Phone); UserData userData = new UserData { Phone = user.Phone, ID = user.ClientId, FullName = user.FullName }; //Nadpisuje cookie dla przechowywania dodatkowych informacji Response.SetAuthCookie(model.Phone, true, userData); //if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") // && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) //{ // return Redirect(returnUrl); //} //else //{ // return RedirectToAction("Index", "Home"); //} return PartialView("SignInSuccessPartial"); } else { ModelState.AddModelError("", "Nieprawidłowe telefon lub hasło!"); } } return PartialView("SignInPartial",model); }
public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (MembershipService.ValidateUser(model.UserName, model.Password)) { FormsService.SignIn(model.UserName, model.RememberMe); if (!String.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } // If we got this far, something failed, redisplay form return View(model); }
/// <summary> /// Logowanie usera /// </summary> /// <returns></returns> public PartialViewResult LogOn() { LogOnModel model = new LogOnModel(); return PartialView("LogOn",model); }