protected void Page_Load(object sender, System.EventArgs e) { Response.CacheControl = "private"; Response.Expires = 0; Response.AddHeader("pragma", "no-cache"); Customer ThisCustomer = (Context.User as InterpriseSuiteEcommercePrincipal).ThisCustomer; if (AppLogic.AppConfigBool("SiteDisclaimerRequired")) { AppLogic.SetSessionCookie("SiteDisclaimerAccepted", String.Empty); } AppLogic.SetSessionCookie("AffiliateID", ""); AppLogic.SetCookie("LocaleSetting", ThisCustomer.LocaleSetting, new TimeSpan(1000, 0, 0, 0, 0)); InterpriseHelper.CreateContactSiteLog(ThisCustomer, "Logout"); Session.Clear(); Session.Abandon(); Response.Cookies.Clear(); Response.Expires = 0; Response.Cache.SetNoStore(); //save the last record of fullmode bool?isRequestedFullMode = ThisCustomer.ThisCustomerSession[DomainConstants.MOBILE_FULLMODE_QUERYTSTRING].TryParseBool(); bool value = (isRequestedFullMode.HasValue) ? isRequestedFullMode.Value : false; //build the query string string addedQueryString = (isRequestedFullMode.HasValue && isRequestedFullMode.Value)? "?" + DomainConstants.MOBILE_FULLMODE_QUERYTSTRING + "=true" : String.Empty; //create anonymous and pass the value again so it will not go to the mobile design ThisCustomer.ThisCustomerSession.Clear(); FormsAuthentication.SignOut(); Security.SignOutCrossDomainCookie(); this.Title = AppLogic.AppConfig("StoreName") + " - Signout"; Literal1.Text = AppLogic.GetString(Literal1.Text.Replace("(!", "").Replace("!)", ""), ThisCustomer.SkinID, ThisCustomer.LocaleSetting); Response.Redirect(String.Format("default.aspx{0}", addedQueryString)); //Response.AddHeader("REFRESH", String.Format("1; URL=default.aspx{0}", addedQueryString)); }
protected void Page_Load(object sender, System.EventArgs e) { Response.CacheControl = "private"; Response.Expires = 0; Response.AddHeader("pragma", "no-cache"); Customer ThisCustomer = (Context.User as InterpriseSuiteEcommercePrincipal).ThisCustomer; if (AppLogic.AppConfigBool("SiteDisclaimerRequired")) { AppLogic.SetSessionCookie("SiteDisclaimerAccepted", String.Empty); } AppLogic.SetSessionCookie("AffiliateID", ""); AppLogic.SetCookie("LocaleSetting", ThisCustomer.LocaleSetting, new TimeSpan(1000, 0, 0, 0, 0)); InterpriseHelper.CreateContactSiteLog(ThisCustomer, "Logout"); ThisCustomer.ThisCustomerSession.Clear(); Session.Clear(); Session.Abandon(); Response.Cookies.Clear(); Response.Expires = 0; Response.Cache.SetNoStore(); //Do special handling of key when IE and site has multiple domain if (Request.Browser.Browser == "IE" && Request.Cookies.Keys.OfType <string>().Where(k => k.ToUpper() == FormsAuthentication.FormsCookieName).Count() > 1) { Request.Cookies.Clear(); Request.Cookies.Remove(FormsAuthentication.FormsCookieName); Response.Cookies.Remove(FormsAuthentication.FormsCookieName); var autCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; if (autCookie != null) { Context.User = new InterpriseSuiteEcommercePrincipal(Customer.MakeAnonymous()); Customer.Current.RequireCustomerRecord(); var customer = Customer.Current; string cookieUserName = customer.ContactGUID.ToString(); string encryptedData = FormsAuthentication.Encrypt( new FormsAuthenticationTicket(1, cookieUserName, DateTime.Now, DateTime.Now.AddMinutes(30), false, string.Empty, FormsAuthentication.FormsCookiePath)); autCookie.Value = encryptedData; Request.Cookies.Set(autCookie); Response.Cookies.Set(autCookie); } } else { FormsAuthentication.SignOut(); } this.Title = AppLogic.AppConfig("StoreName") + " - Signout"; Literal1.Text = AppLogic.GetString(Literal1.Text.Replace("(!", "").Replace("!)", ""), ThisCustomer.SkinID, ThisCustomer.LocaleSetting); Response.AddHeader("REFRESH", "1; URL=default.aspx"); }
protected void LoginButton_Click(object sender, EventArgs e) { string EMailField = EMail.Text.ToLower(); string PasswordField = Password.Text; string NewCustomerID = string.Empty; if (AppLogic.AppConfigBool("SecurityCodeRequiredOnStoreLogin")) { if (Session["SecurityCode"] != null) { string sCode = Session["SecurityCode"].ToString(); string fCode = SecurityCode.Text; bool codeMatch = false; if (AppLogic.AppConfigBool("Captcha.CaseSensitive")) { if (fCode.Equals(sCode)) { codeMatch = true; } } else { if (fCode.Equals(sCode, StringComparison.InvariantCultureIgnoreCase)) { codeMatch = true; } } if (!codeMatch) { ErrorMsgLabel.Text = string.Format(AppLogic.GetString("signin.aspx.22", SkinID, ThisCustomer.LocaleSetting, true), string.Empty, string.Empty); ErrorPanel.Visible = true; SecurityCode.Text = string.Empty; SecurityImage.ImageUrl = "Captcha.ashx?id=1"; return; } } else { ErrorMsgLabel.Text = string.Format(AppLogic.GetString("signin.aspx.22", SkinID, ThisCustomer.LocaleSetting, true), string.Empty, string.Empty); ErrorPanel.Visible = true; SecurityCode.Text = string.Empty; SecurityImage.ImageUrl = "Captcha.ashx?id=1"; return; } } if (string.IsNullOrEmpty(EMailField) || string.IsNullOrEmpty(EMailField.Trim()) || string.IsNullOrEmpty(PasswordField) || string.IsNullOrEmpty(PasswordField.Trim())) { DisplayInvalidLogin(); return; } if (CheckValidEmail()) { Customer customerWithValidLogin = Customer.FindByLogin(EMail.Text, PasswordField); if (null == customerWithValidLogin) { DisplayInvalidLogin(); return; } bool isAllowed = InterpriseHelper.ValidateContactSubscription(customerWithValidLogin); if (!isAllowed) { DisplayInvalidLogin(); return; } var rememberMeCookie = new HttpCookie(REMEMBERME_COOKIE_NAME); Response.Cookies.Remove(REMEMBERME_COOKIE_NAME); //check if remember me if (PersistLogin.Checked == true) { rememberMeCookie.Value = customerWithValidLogin.ContactGUID.ToString(); rememberMeCookie.Expires = DateTime.Now.AddDays(30); Response.Cookies.Add(rememberMeCookie); } else { rememberMeCookie.Expires = DateTime.Now.AddYears(-10); } //save the last record of fullmode customerWithValidLogin.FullModeInMobile = ThisCustomer.FullModeInMobile; // dis-associate the session information if any.. ThisCustomer.ThisCustomerSession.Clear(); // we've got a good login... AppLogic.ExecuteSigninLogic(ThisCustomer.CustomerCode, ThisCustomer.ContactCode, customerWithValidLogin.CustomerCode, string.Empty, customerWithValidLogin.ContactCode); // we've got a good login: FormPanel.Visible = false; ExecutePanel.Visible = true; ThisCustomer.ThisCustomerSession["ContactID"] = customerWithValidLogin.ContactGUID.ToString(); SignInExecuteLabel.Text = AppLogic.GetString("signin.aspx.2", SkinID, ThisCustomer.LocaleSetting); InterpriseHelper.CreateContactSiteLog(customerWithValidLogin, "Login"); string cookieUserName = customerWithValidLogin.ContactGUID.ToString(); bool createPersistentCookie = PersistLogin.Checked; //support cross domain login Security.SignOutCrossDomainCookie(); Security.CreateLoginCookie(cookieUserName, createPersistentCookie); string sReturnURL = FormsAuthentication.GetRedirectUrl(cookieUserName, createPersistentCookie); if (sReturnURL.Length == 0) { sReturnURL = ReturnURL.Text; } if (sReturnURL.Length == 0) { if (DoingCheckout.Checked) { sReturnURL = "shoppingcart.aspx"; } else { sReturnURL = "default.aspx"; } } if (sReturnURL.Contains("default.aspx")) { sReturnURL = sReturnURL.Replace("default", "account"); } if (sReturnURL.Contains("download.aspx")) { sReturnURL = sReturnURL + "&sid=" + CommonLogic.QueryStringCanBeDangerousContent("sid"); } Response.AddHeader("REFRESH", "1; URL=" + Security.UrlDecode(sReturnURL)); } }
protected void LoginButton_Click(object sender, EventArgs e) { string EMailField = EMail.Text.ToLower(); string PasswordField = Password.Text; if (AppLogic.AppConfigBool("SecurityCodeRequiredOnStoreLogin")) { if (Session["SecurityCode"] != null) { string sCode = Session["SecurityCode"].ToString(); string fCode = SecurityCode.Text; bool codeMatch = false; if (AppLogic.AppConfigBool("Captcha.CaseSensitive")) { if (fCode.Equals(sCode)) { codeMatch = true; } } else { if (fCode.Equals(sCode, StringComparison.InvariantCultureIgnoreCase)) { codeMatch = true; } } if (!codeMatch) { ErrorMsgLabel.Text = string.Format(AppLogic.GetString("signin.aspx.22", SkinID, ThisCustomer.LocaleSetting), string.Empty, string.Empty); ErrorPanel.Visible = true; SecurityCode.Text = string.Empty; SecurityImage.ImageUrl = "Captcha.ashx?id=1"; return; } } else { ErrorMsgLabel.Text = string.Format(AppLogic.GetString("signin.aspx.22", SkinID, ThisCustomer.LocaleSetting), string.Empty, string.Empty); ErrorPanel.Visible = true; SecurityCode.Text = String.Empty; SecurityImage.ImageUrl = "Captcha.ashx?id=1"; return; } } if (string.IsNullOrEmpty(EMailField) || string.IsNullOrEmpty(EMailField.Trim()) || string.IsNullOrEmpty(PasswordField) || string.IsNullOrEmpty(PasswordField.Trim())) { DisplayInvalidLogin(); return; } if (!CheckValidEmail()) { return; } var customerWithValidLogin = Customer.FindByLogin(EMail.Text, PasswordField); if (customerWithValidLogin == null) { DisplayInvalidLogin(); return; } bool isAllowed = InterpriseHelper.ValidateContactSubscription(customerWithValidLogin); if (!isAllowed) { DisplayInvalidLogin(); return; } //check if remember me if (PersistLogin.Checked) { CookieTool.Add(REMEMBERME_COOKIE_NAME, customerWithValidLogin.ContactGUID.ToString(), DateTime.Now.AddDays(30)); } else { CookieTool.Add(REMEMBERME_COOKIE_NAME, string.Empty, DateTime.Now.AddYears(-10)); } //save the last record of fullmode to the loggedin user to maintain the view mode customerWithValidLogin.FullModeInMobile = ThisCustomer.FullModeInMobile; // dis-associate the session information if any.. ThisCustomer.ThisCustomerSession.Clear(); // we've got a good login... AppLogic.ExecuteSigninLogic(ThisCustomer.CustomerCode, ThisCustomer.ContactCode, customerWithValidLogin.CustomerCode, string.Empty, customerWithValidLogin.ContactCode); // we've got a good login: FormPanel.Visible = false; ExecutePanel.Visible = true; ThisCustomer.ThisCustomerSession["ContactID"] = customerWithValidLogin.ContactGUID.ToString(); SignInExecuteLabel.Text = AppLogic.GetString("signin.aspx.2", SkinID, ThisCustomer.LocaleSetting); InterpriseHelper.CreateContactSiteLog(customerWithValidLogin, "Login"); string cookieUserName = customerWithValidLogin.ContactGUID.ToString(); bool createPersistentCookie = PersistLogin.Checked; //To handle multiple domain ie bug if (Request.Browser.Browser == "IE" && Request.Cookies.Keys.OfType <string>() .Where(k => k.ToUpper() == FormsAuthentication.FormsCookieName) .Count() > 1) { var autCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; if (autCookie != null) { string encryptedData = FormsAuthentication.Encrypt( new FormsAuthenticationTicket(1, cookieUserName, DateTime.Now, DateTime.Now.AddMinutes(30), createPersistentCookie, string.Empty, FormsAuthentication.FormsCookiePath)); autCookie.Value = encryptedData; Request.Cookies.Set(autCookie); Response.Cookies.Set(autCookie); } } else { FormsAuthentication.SetAuthCookie(cookieUserName, createPersistentCookie); } string sReturnURL = DoingCheckout.Checked ? "shoppingcart.aspx" : "default.aspx"; if (sReturnURL.Contains("default.aspx")) { sReturnURL = "account.aspx"; } Response.AddHeader("REFRESH", "1; URL=" + sReturnURL.ToUrlDecode()); }