public ActionResult Login(Login model) { #region Ortak Set Edilecek Değerler ViewBag.Success = true; #endregion ModelState.Remove("RememberMe"); if (ModelState.IsValid) { BaseClasses.BaseLogin objLogin = new BaseClasses.BaseLogin(); if (objLogin.UserValidaton(model.Email_Login, model.Password_Login)) { SessionContext newSession = SessionContext.StartSession(); newSession.ActiveUser.UserUid = objLogin.GetUserUid(); newSession.ActiveUser.UserNameAndSurname = objLogin.GetUserNameAndSurName(); newSession.ActiveUser.UserEmail = objLogin.GetEmail(); newSession.ActiveUser.Name = objLogin.GetName(); newSession.ActiveUser.Surname = objLogin.GetSurname(); newSession.ActiveUser.PublicUserName = objLogin.GetPublicUsername(); newSession.ActiveUser.TimeZoneInfoUser = objLogin.GetTimeZoneInfoUser(); BaseClasses.SessionKeeper.AddCurrentSession(); BaseClasses.SessionKeeper.AddLoggedInUserToDataBase("login"); FormsAuthentication.SetAuthCookie(newSession.ActiveUser.UserUid.ToString(), false); if (model.RememberMe) { BaseClasses.BaseFunctions.getInstance().SetLoginCookie(newSession, System.Web.HttpContext.Current.Response); } return(RedirectToAction("Index", "Home")); } else { ViewBag.Success = false; ModelState.AddModelError("Error", Resources.GlobalResource.login_failed); } } else { } return(View(model)); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { var context = filterContext.HttpContext; //string lang = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName; //if (string.IsNullOrEmpty(lang)) // lang = "tr"; //string redirectTo = "~/" + lang + "/Account/Login"; //string redirectToLogOut = "~/" + lang + "/Account/LogOff"; string redirectTo = "~/Account/Login"; ///Kullanıcı Login değilse İşlem Post ise if (BaseDB.SessionContext.Current == null || BaseDB.SessionContext.Current.ActiveUser == null) { HttpCookie ck = System.Web.HttpContext.Current.Request.Cookies["DCMGRUP23"]; if (ck != null) { try { BaseClasses.BaseLogin objLogin = new BaseClasses.BaseLogin(); FormsAuthenticationTicket oldTicket = FormsAuthentication.Decrypt(ck.Value); objLogin.LoginFromRememberMe(oldTicket.Name); } catch (Exception exp) { } } } if (!context.Request.IsAjaxRequest() && SessionContext.IsSessionNull()) { filterContext.Result = new RedirectResult(redirectTo); } base.OnActionExecuting(filterContext); }
public ActionResult SetCookie() { bool result = false; if (BaseDB.SessionContext.Current == null || BaseDB.SessionContext.Current.ActiveUser == null) { HttpCookie ck = System.Web.HttpContext.Current.Request.Cookies["DCMGRUP23"]; if (ck != null) { try { BaseClasses.BaseLogin objLogin = new BaseClasses.BaseLogin(); FormsAuthenticationTicket oldTicket = FormsAuthentication.Decrypt(ck.Value); result = objLogin.LoginFromRememberMe(oldTicket.Name); } catch (Exception exp) { } } } return(Content(result.ToString(), "text/html"));; }