Exemplo n.º 1
0
 public ActionResult LogOn(LogOnModel model, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         if (ValidateUser(model.UserName, model.Password))
         {
             return RedirectToAction("Index", "Home");
         }
         else
         {
             ModelState.AddModelError("", ErrorCodeToString("LoginInCorrecto"));
             return View();
         }
     }
     ModelState.AddModelError("", ErrorCodeToString("LoginInCorrecto"));
     return RedirectToAction("Index", "Home");
 }
Exemplo n.º 2
0
 public ActionResult LogOn(LogOnModel model, string returnUrl)
 {
     if (ModelState.IsValid) {
         if (ValidateUser(model.UserName, model.Password))
         {
             return RedirectToAction("Home", "Admin");
         }
         else
         {
             TempData["Error"] = "The user name or password provided is incorrect.";
         }
     }
     return RedirectToAction("Index", "Admin");
 }
Exemplo n.º 3
0
        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);
        }