Exemplo n.º 1
0
 public ActionResult Login(LoginModel model)
 {
     if(ModelState.IsValid)
     {
         if(_authenticator.Authenticate(model.UserName, model.Password))
         {
             FormsAuthentication.SetAuthCookie(model.UserName, false);
             return RedirectToAction("Index", "Home");
         }
         else
         {
             ModelState.AddModelError(string.Empty, "Invalid username/password");
             model.Password = null;
             return View(model);
         }
     }
     else
     {
         return View(new LoginModel());
     }
 }
Exemplo n.º 2
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                return RedirectToLocal(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }
Exemplo n.º 3
0
 public ActionResult Login(LoginModel model)
 {
     FederatedAuthentication.WSFederationAuthenticationModule.SignIn(null);
     return null;
 }