public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { RedisUser ru = RedisHelper.LoginUser(model.UserName, model.Password); if (ru == null) { ModelState.AddModelError("", "The user name or password provided is incorrect."); } else { FormsAuthentication.SetAuthCookie(model.UserName, false); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { RedisUser ru = RedisHelper.RegisterUser(model.UserName, model.Password); if (ru == null) { ModelState.AddModelError("", "Sorry that username already exists"); } else { FormsAuthentication.SetAuthCookie(model.UserName, false); HttpContext.Session.Add("ru", ru); return(RedirectToAction("Index", "Home")); } } // If we got this far, something failed, redisplay form return(View(model)); }