Example #1
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            model.UserName = model.UserName.ToLower();
            model.Password = model.Password.ToLower();
            if (ModelState.IsValid && UserModule.ValidateUser(model.UserName, model.Password))
            {
                var    user     = UserModule.GetUser(model.UserName);
                string userData = model.UserName + "," + user.Role + "," + user.Department.Id + "," + user.Name;
                //FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, model.UserName, DateTime.Now, DateTime.Now.AddDays(1), model.RememberMe, userData);
                string     encTicket             = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
                cookie.Expires = ticket.Expiration;
                Response.Cookies.Add(cookie);
                ElmahLog.Create("Successful Login by user: "******"Failed Login by User: "******", Password : "******"", "The user name or password provided is incorrect.");
            return(View(model));
        }
Example #2
0
 protected void Session_Start()
 {
     ElmahLog.Create("Session started from :" + Request.Headers["X-Real-IP"]);
 }