public bool userSetUpValidation(string username) { using (MPRContext3 mx3 = new MPRContext3()) { //var user = db.Applicants.Where(a => a.UserEmailAddress.Equals(username) && a.password.Equals(password)).SingleOrDefault(); var user = mx3.CorUserSetUpSet.Where(a => a.LoginID.Trim().ToUpper().Equals(username.ToUpper().Trim())).FirstOrDefault(); if (user != null) { System.Web.HttpContext.Current.Session["session_userfullname"] = user.Name; System.Web.HttpContext.Current.Session["session_loggedinUser"] = user.Name; System.Web.HttpContext.Current.Session["session_userstaffid"] = user.StaffID; System.Web.HttpContext.Current.Session["session_photourlpath"] = user.PhotoUrl; System.Web.HttpContext.Current.Session["session_isreportuser"] = user.IsReportUser; return(true); } } return(false); }
public bool userValidation(string username, string password) { using (MPRContext3 mx3 = new MPRContext3()) { //var user = db.Applicants.Where(a => a.UserEmailAddress.Equals(username) && a.password.Equals(password)).SingleOrDefault(); var user = mx3.CorUserSetUpSet.Where(a => a.LoginID.Trim().ToUpper().Equals(username.ToUpper()) && password.Equals("@password")).FirstOrDefault(); if (user != null) { FormsAuthentication.SetAuthCookie(username, false); AccountLoginModel serializeModel = new AccountLoginModel(); //serializeModel.CompanyCode = companyCode; JavaScriptSerializer serializer = new JavaScriptSerializer(); string userData = serializer.Serialize(serializeModel); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddHours(10), false, userData); string encTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); faCookie.Expires = false ? authTicket.Expiration : DateTime.Now.AddHours(10); System.Web.HttpContext.Current.Response.Cookies.Add(faCookie); System.Web.HttpContext.Current.Session["session_userfullname"] = user.Name; System.Web.HttpContext.Current.Session["session_loggedinUser"] = user.Name; System.Web.HttpContext.Current.Session["session_userstaffid"] = user.StaffID; System.Web.HttpContext.Current.Session["session_photourlpath"] = user.PhotoUrl; System.Web.HttpContext.Current.Session["session_isreportuser"] = user.IsReportUser; return(true); } } return(false); }