Пример #1
0
        public ActionResult Login(LoginModel request)
        {
            TblUser user = _user.ValidarLogin(new TblUser()
            {
                Email = request.Email,
                Senha = request.Senha
            });

            if (user != null)
            {
                string userId = user.PK_User.ToString();

                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                  "USER_LOGADO",
                  DateTime.Now,
                  DateTime.Now.AddMinutes(30),
                  false,
                  userId,
                  FormsAuthentication.FormsCookiePath);

                // Encrypt the ticket.
                string encTicket = FormsAuthentication.Encrypt(ticket);

                // Create the cookie.
                Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

                return RedirectToAction("Index", "Home");
            }
            else
            {
                return View("Login", request);
            }
        }
Пример #2
0
 public JsonResult Forget(LoginModel request)
 {
     _user.ForgetPassword(request.EmailForget);
     return Json("Solicitado uma nova senha, será enviado no email indicado");
 }