Ejemplo n.º 1
0
        public ActionResult Index(LoginViewModel login)
        {
            if (!ModelState.IsValid) return View();

            if (!userRepo.ValidateUser(login))
            {
                ModelState.AddModelError("", "Incorrect username or password");

                return View();
            }

            var authTicket = new FormsAuthenticationTicket(
                    1,
                    login.UserName,
                    DateTime.Now,
                    DateTime.Now.AddMinutes(20),  // expiry
                    login.RememberMe,
                    "", //roles
                    "/"
            );

            //encrypt the ticket and add it to a cookie
            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket));
            Response.Cookies.Add(cookie);

            return Redirect("UserHome");
        }
Ejemplo n.º 2
0
 public bool ValidateUser(LoginViewModel login)
 {
     return true;
 }
Ejemplo n.º 3
0
 public bool ValidateUser(LoginViewModel login)
 {
     //return UserAgent.ValidateUser(login);
     return true;
 }