Esempio n. 1
0
        public ActionResult SignIn(SignInViewModel signInViewModel)
        {
            User user = userDetails.SignIn(signInViewModel.Gmail, signInViewModel.Password);

            if (user != null)
            {
                FormsAuthentication.SetAuthCookie(user.Gmail, false);
                var    authTicket      = new FormsAuthenticationTicket(1, user.Gmail, DateTime.Now, DateTime.Now.AddMinutes(20), false, user.UserType);
                string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                var    authCookie      = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                HttpContext.Response.Cookies.Add(authCookie);
                TempData["alertMessage"] = "Login successfull";
                return(RedirectToAction("HomePage", "Home"));
            }
            TempData["Invalid"] = "Invalid Username or Password";
            Response.Write("<script language='javascript'>alert('UserName or Password is incorrect');</script>");
            //   TempData["alertMessage"] = "Invalid Gmail or Password";
            return(RedirectToAction("SignIn", "User"));
        }