public ActionResult Login(AuthLogin form, string returnUrl) { // we use the form to change data and pass it to next view form.Test = "Value of Test changes after POST "; form.Valid = "The form info is valid"; // check for invalid input if (!ModelState.IsValid) { form.Valid = "! - The form is INVALID"; return View(form); } // Authentication for RoleProvider.cs - GetRolesForUser(username) FormsAuthentication.SetAuthCookie(form.Username, true); // THEN AUTHORIZATION OCCURS -> RoleProvider.cs - GetRolesForUser(username) if (!string.IsNullOrWhiteSpace(returnUrl)) { // might want to check that we don't redirect to an external domain for hacking safe return Redirect(returnUrl); } return RedirectToRoute("Home"); }
public ActionResult Login (AuthLogin form) { if (!ModelState.IsValid) return View(form); FormsAuthentication.SetAuthCookie(form.UserName,true); return Content("Hi there "+form.UserName); }
public ActionResult Login(AuthLogin form, string returnUrl) { if (!ModelState.IsValid) return View(form); FormsAuthentication.SetAuthCookie(form.Username, true); if(!string.IsNullOrWhiteSpace(returnUrl)) return Redirect(returnUrl); return RedirectToRoute("home"); }
public ActionResult Login(AuthLogin form, string returnUrl) { // Actual validation would be here if (!ModelState.IsValid) return View(form); // This validates the username. Hit a database here FormsAuthentication.SetAuthCookie(form.Username, true); if (!string.IsNullOrWhiteSpace(returnUrl)) return Redirect(returnUrl); return RedirectToRoute("home"); }
public ActionResult Login(AuthLogin form, string returnurl) { var user = Database.Session.Query<User>().FirstOrDefault(u => u.Username == form.Username); if (user == null) SimpleBlog.Models.User.FakeHash(); if(user == null || !user.CheckPassword(form.Password)) ModelState.AddModelError("Username","Username or password is incorrect"); if (!ModelState.IsValid) return View(form); FormsAuthentication.SetAuthCookie(form.Username, true); if (!string.IsNullOrWhiteSpace(returnurl)) return Redirect(returnurl); return RedirectToRoute(""); }