Esempio n. 1
0
        public ActionResult Login(LoginModel model)
        {
            var repository = new UsersRepository();
            var verify = repository.Login(model.Password, model.Username);

            try
            {
                if (verify)
                {
                    var ticket = new FormsAuthenticationTicket(1,
                                                           model.Username,
                                                           DateTime.Now,
                                                           DateTime.Now.AddSeconds(30),
                                                           model.Persistent,
                                                           "");

                    var strEncryptedTicket = FormsAuthentication.Encrypt(ticket);
                    var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, strEncryptedTicket);
                    Response.Cookies.Add(cookie);

                    return RedirectToAction(Actions.Index, HomeController.Name);
                }
            }
            catch (Exception)
            {

            }

            return View(Views.Login);
        }
Esempio n. 2
0
        public ActionResult LogOut(LoginModel model)
        {
            Response.Cookies.Remove(".ASPXAUTH");

            return View(Views.Login);
        }
Esempio n. 3
0
 public ActionResult Index(LoginModel model)
 {
     return View(Views.Login);
 }