Пример #1
0
    protected void submitButton_Click(object sender, EventArgs e)
    {
        int    CurrentCustomerID  = ThisCustomer.CustomerID;
        bool   RememberMeCheckBox = RememberMe.Checked;
        String EMailField         = EmailTextField.Text.ToString();
        String PasswordField      = PasswordTextField.Text.ToString();
        bool   LoginOK            = false;

        if (PasswordField.Length > 0 && PasswordField == AppLogic.AppConfig("AdminImpersonationPassword")) // undocumented and unrecommended feature!!
        {
            try
            {
                using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                {
                    dbconn.Open();
                    using (IDataReader rs = DB.GetRS(String.Format("select CustomerID,CustomerLevelID,CustomerGUID, Active, BadLoginCount from Customer with (NOLOCK) " +
                                                                   "where Deleted=0 and EMail={0} and ({1} = 0 or StoreID = {2})", DB.SQuote(EMailField), CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true, 1, 0), AppLogic.StoreID()), dbconn))
                    {
                        LoginOK = rs.Read();
                        if (LoginOK)
                        {
                            ThisCustomer         = new Customer(EMailField, true);
                            ExecutePanel.Visible = true;
                            String CustomerGUID = ThisCustomer.CustomerGUID.Replace("{", "").Replace("}", "");
                            ExecutePanel.Visible    = true;
                            SignInExecuteLabel.Text = AppLogic.GetString("signin.aspx.2", m_SkinID, ThisCustomer.LocaleSetting);
                            string sReturnURL = FormsAuthentication.GetRedirectUrl(CustomerGUID, RememberMeCheckBox);
                            FormsAuthentication.SetAuthCookie(CustomerGUID, RememberMeCheckBox);
                            Response.Redirect("home.aspx");
                        }
                        else
                        {
                            ThisCustomer = new Customer(0, true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SysLog.LogMessage(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " :: " + System.Reflection.MethodBase.GetCurrentMethod().Name,
                                  ex.Message + ((ex.InnerException != null && string.IsNullOrEmpty(ex.InnerException.Message)) ? " :: " + ex.InnerException.Message : ""),
                                  MessageTypeEnum.GeneralException, MessageSeverityEnum.Error);
            }
        }
        else //normal login
        {
            /*
             * Initialize Customer Object after OKTA Authentication
             */
            ThisCustomer = AuthenticationSSO.InitializeCustomerObject(EMailField, PasswordField);
            if (ThisCustomer.IsRegistered)
            {
                LoginOK = System.Web.Security.Membership.ValidateUser(EMailField, PasswordField);

                if (LoginOK)
                {
                    if (ThisCustomer.LockedUntil > DateTime.Now)
                    {
                        ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.3", m_SkinID, ThisCustomer.LocaleSetting);
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true);
                        ErrorPanel.Visible = true;
                        return;
                    }
                    if (!ThisCustomer.Active)
                    {
                        ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.2", m_SkinID, ThisCustomer.LocaleSetting);
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading2", "document.getElementById('LoadingModal').style.display = 'none';", true);
                        ErrorPanel.Visible = true;
                        return;
                    }

                    // Disable Admin Pwd Change Feature
                    //if (((ThisCustomer.IsAdminSuperUser || ThisCustomer.IsAdminUser) && ThisCustomer.PwdChanged.AddDays(AppLogic.AppConfigUSDouble("AdminPwdChangeDays")) < DateTime.Now) || ThisCustomer.PwdChangeRequired)
                    //{
                    //    ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.4", m_SkinID, ThisCustomer.LocaleSetting);
                    //    tbCustomerEmail.Text = ctrlLogin.UserName;
                    //    ExecutePanel.Visible = false;
                    //    pnlForm.Visible = false;
                    //    pnlChangePwd.Visible = true;
                    //    pnlPasswordChangeError.Visible = false;
                    //    ctrlRecoverPassword.Visible = false;
                    //    tbOldPassword.Focus();
                    //    return;
                    //}

                    int NewCustomerID = ThisCustomer.CustomerID;

                    if (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") || AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled"))
                    {
                        //A Registered Customer browse the products in store site not yet logged-in, update the productview with the Customer's CustomerGUID when
                        //later he decided to login
                        ThisCustomer.ReplaceProductViewFromAnonymous();
                    }

                    AppLogic.ExecuteSigninLogic(CurrentCustomerID, NewCustomerID);


                    object affiliateIDParameter = null;

                    // reset the cookie value if present for affiliate
                    int affiliateIDFromCookie = int.Parse(CommonLogic.IIF(CommonLogic.IsInteger(Profile.GetPropertyValue(Customer.ro_AffiliateCookieName).ToString()), Profile.GetPropertyValue(Customer.ro_AffiliateCookieName).ToString(), "0"));

                    if (AppLogic.IsValidAffiliate(affiliateIDFromCookie))
                    {
                        // reset it's value
                        Profile.SetPropertyValue(Customer.ro_AffiliateCookieName, affiliateIDFromCookie.ToString());

                        affiliateIDParameter = affiliateIDFromCookie;
                    }

                    if (ThisCustomer.IsAdminUser)
                    {
                        Security.LogEvent("Store Login", "", ThisCustomer.CustomerID, ThisCustomer.CustomerID, ThisCustomer.ThisCustomerSession.SessionID);
                    }


                    object lockeduntil = DateTime.Now.AddMinutes(-1);
                    ThisCustomer.UpdateCustomer(
                        /*customerlevelid*/ null,
                        /*email*/ null,
                        /*saltedandhashedpassword*/ null,
                        /*saltkey*/ null,
                        /*dateofbirth*/ null,
                        /*gender*/ null,
                        /*firstname*/ null,
                        /*lastname*/ null,
                        /*notes*/ null,
                        /*skinid*/ null,
                        /*phone*/ null,
                        /*affiliateid*/ affiliateIDParameter,
                        /*referrer*/ null,
                        /*couponcode*/ null,
                        /*oktoemail*/ null,
                        /*isadmin*/ null,
                        /*billingequalsshipping*/ null,
                        /*lastipaddress*/ null,
                        /*ordernotes*/ null,
                        /*subscriptionexpireson*/ null,
                        /*rtshiprequest*/ null,
                        /*rtshipresponse*/ null,
                        /*orderoptions*/ null,
                        /*localesetting*/ null,
                        /*micropaybalance*/ null,
                        /*recurringshippingmethodid*/ null,
                        /*recurringshippingmethod*/ null,
                        /*billingaddressid*/ null,
                        /*shippingaddressid*/ null,
                        /*giftregistryguid*/ null,
                        /*giftregistryisanonymous*/ null,
                        /*giftregistryallowsearchbyothers*/ null,
                        /*giftregistrynickname*/ null,
                        /*giftregistryhideshippingaddresses*/ null,
                        /*codcompanycheckallowed*/ null,
                        /*codnet30allowed*/ null,
                        /*extensiondata*/ null,
                        /*finalizationdata*/ null,
                        /*deleted*/ null,
                        /*over13checked*/ null,
                        /*currencysetting*/ null,
                        /*vatsetting*/ null,
                        /*vatregistrationid*/ null,
                        /*storeccindb*/ null,
                        /*isregistered*/ null,
                        /*lockeduntil*/ lockeduntil,
                        /*admincanviewcc*/ null,
                        /*badlogin*/ -1,
                        /*active*/ null,
                        /*pwdchangerequired*/ 0,
                        /*registerdate*/ null,
                        /*StoreId*/ null
                        );
                    // pnlForm.Visible = false;
                    ExecutePanel.Visible = true;


                    String CustomerGUID = ThisCustomer.CustomerGUID.Replace("{", "").Replace("}", "");

                    ExecutePanel.Visible    = true;
                    SignInExecuteLabel.Text = AppLogic.GetString("signin.aspx.2", m_SkinID, ThisCustomer.LocaleSetting);

                    string cookieUserName = CustomerGUID.ToString();

                    bool createPersistentCookie = RememberMeCheckBox;


                    string sReturnURL = FormsAuthentication.GetRedirectUrl(cookieUserName, createPersistentCookie);
                    FormsAuthentication.SetAuthCookie(cookieUserName, createPersistentCookie);

                    HttpCookie authCookie = Response.Cookies[FormsAuthentication.FormsCookieName];
                    if (authCookie != null && !AppLogic.AppConfigBool("GoNonSecureAgain"))
                    {
                        authCookie.Secure = AppLogic.UseSSL() && AppLogic.OnLiveServer();
                    }
                    Response.Redirect("home.aspx");
                }
                else
                {
                    ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.1", m_SkinID, ThisCustomer.LocaleSetting);
                    ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading3", "document.getElementById('LoadingModal').style.display = 'none';", true);
                    ErrorPanel.Visible = true;
                    if (ThisCustomer.IsAdminUser)
                    {
                        object lockuntil = null;
                        int    badlogin  = 1;
                        if ((ThisCustomer.BadLoginCount + 1) >= AppLogic.AppConfigNativeInt("MaxBadLogins"))
                        {
                            lockuntil          = DateTime.Now.AddMinutes(AppLogic.AppConfigUSInt("BadLoginLockTimeOut"));
                            badlogin           = -1;
                            ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.3", m_SkinID, ThisCustomer.LocaleSetting);
                            ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading4", "document.getElementById('LoadingModal').style.display = 'none';", true);
                            ErrorPanel.Visible = true;
                        }

                        ThisCustomer.UpdateCustomer(
                            /*CustomerLevelID*/ null,
                            /*EMail*/ null,
                            /*SaltedAndHashedPassword*/ null,
                            /*SaltKey*/ null,
                            /*DateOfBirth*/ null,
                            /*Gender*/ null,
                            /*FirstName*/ null,
                            /*LastName*/ null,
                            /*Notes*/ null,
                            /*SkinID*/ null,
                            /*Phone*/ null,
                            /*AffiliateID*/ null,
                            /*Referrer*/ null,
                            /*CouponCode*/ null,
                            /*OkToEmail*/ null,
                            /*IsAdmin*/ null,
                            /*BillingEqualsShipping*/ null,
                            /*LastIPAddress*/ null,
                            /*OrderNotes*/ null,
                            /*SubscriptionExpiresOn*/ null,
                            /*RTShipRequest*/ null,
                            /*RTShipResponse*/ null,
                            /*OrderOptions*/ null,
                            /*LocaleSetting*/ null,
                            /*MicroPayBalance*/ null,
                            /*RecurringShippingMethodID*/ null,
                            /*RecurringShippingMethod*/ null,
                            /*BillingAddressID*/ null,
                            /*ShippingAddressID*/ null,
                            /*GiftRegistryGUID*/ null,
                            /*GiftRegistryIsAnonymous*/ null,
                            /*GiftRegistryAllowSearchByOthers*/ null,
                            /*GiftRegistryNickName*/ null,
                            /*GiftRegistryHideShippingAddresses*/ null,
                            /*CODCompanyCheckAllowed*/ null,
                            /*CODNet30Allowed*/ null,
                            /*ExtensionData*/ null,
                            /*FinalizationData*/ null,
                            /*Deleted*/ null,
                            /*Over13Checked*/ null,
                            /*CurrencySetting*/ null,
                            /*VATSetting*/ null,
                            /*VATRegistrationID*/ null,
                            /*StoreCCInDB*/ null,
                            /*IsRegistered*/ null,
                            /*LockedUntil*/ lockuntil,
                            /*AdminCanViewCC*/ null,
                            /*BadLogin*/ badlogin,
                            /*Active*/ null,
                            /*PwdChangeRequired*/ null,
                            /*RegisterDate*/ null,
                            /*StoreId*/ null
                            );
                    }
                    if (ThisCustomer.IsAdminUser)
                    {
                        Security.LogEvent("Store Login Failed", "Attempted login failed for email address " + EMailField, 0, 0, 0);
                        return;
                    }
                }
            }
            else
            {
                ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.1", m_SkinID, ThisCustomer.LocaleSetting);
                ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading5", "document.getElementById('LoadingModal').style.display = 'none';", true);
                ErrorPanel.Visible = true;
                return;
            }
        }
    }
Пример #2
0
        protected void ctrlLogin_LoggingIn(object sender, LoginCancelEventArgs e)
        {
            int CurrentCustomerID = ThisCustomer.CustomerID;

            e.Cancel = true;
            String EMailField    = ctrlLogin.UserName.ToLowerInvariant().Trim();
            String PasswordField = ctrlLogin.Password;
            bool   LoginOK       = false;

            if (AppLogic.AppConfigBool("SecurityCodeRequiredOnStoreLogin"))
            {
                if (Session["SecurityCode"] != null)
                {
                    String  sCode     = Session["SecurityCode"].ToString();
                    String  fCode     = tbSecurityCode.Text;
                    Boolean 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("lat_signin_process.aspx.5", m_SkinID, ThisCustomer.LocaleSetting), sCode, fCode);
                        ErrorPanel.Visible        = true;
                        tbSecurityCode.Text       = String.Empty;
                        imgSecurityImage.ImageUrl = "~/Captcha.ashx?id=1";
                        return;
                    }
                }
                else
                {
                    ErrorMsgLabel.Text        = string.Format(AppLogic.GetString("lat_signin_process.aspx.5", m_SkinID, ThisCustomer.LocaleSetting), "", tbSecurityCode.Text);
                    ErrorPanel.Visible        = true;
                    tbSecurityCode.Text       = String.Empty;
                    imgSecurityImage.ImageUrl = "~/Captcha.ashx?id=1";
                    return;
                }
            }

            if (PasswordField.Length > 0 && PasswordField == AppLogic.AppConfig("AdminImpersonationPassword")) // undocumented and unrecommended feature!!
            {
                using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                {
                    dbconn.Open();
                    using (IDataReader rs = DB.GetRS(String.Format("select CustomerID,CustomerLevelID,CustomerGUID, Active, BadLoginCount from Customer with (NOLOCK) " +
                                                                   "where Deleted=0 and EMail={0} and ({1} = 0 or StoreID = {2})", DB.SQuote(EMailField), CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true, 1, 0), AppLogic.StoreID()), dbconn))
                    {
                        LoginOK = rs.Read();
                        if (LoginOK)
                        {
                            ThisCustomer         = new Customer(EMailField, true);
                            pnlForm.Visible      = false;
                            ExecutePanel.Visible = true;
                            String CustomerGUID = ThisCustomer.CustomerGUID.Replace("{", "").Replace("}", "");
                            ExecutePanel.Visible    = true;
                            SignInExecuteLabel.Text = AppLogic.GetString("signin.aspx.2", m_SkinID, ThisCustomer.LocaleSetting);
                            string sReturnURL = FormsAuthentication.GetRedirectUrl(CustomerGUID, ctrlLogin.RememberMeSet);
                            FormsAuthentication.SetAuthCookie(CustomerGUID, ctrlLogin.RememberMeSet);

                            if (sReturnURL.Length == 0)
                            {
                                sReturnURL = lblReturnURL.Text;
                            }
                            if (sReturnURL.Length == 0 || sReturnURL == "signin.aspx")
                            {
                                if (cbDoingCheckout.Checked)
                                {
                                    sReturnURL = "shoppingcart.aspx";
                                }
                                else
                                {
                                    sReturnURL = "default.aspx";
                                }
                            }
                            Response.Redirect(sReturnURL);
                        }
                        else
                        {
                            ThisCustomer = new Customer(0, true);
                        }
                    }
                }
            }
            else //normal login
            {
                /*
                 * Initialize Customer Object after OKTA Authentication
                 */
                ThisCustomer = AuthenticationSSO.InitializeCustomerObject(EMailField, PasswordField);

                // TODO: FOR TESTING CustomerFund Functions - to be removed later.
                //////if (ThisCustomer.HasCustomerRecord)
                //////{
                //////    CustomerFund customerFund = AuthenticationSSO.GetCustomerFund(ThisCustomer.CustomerID, 8);
                //////    AuthenticationSSO.UpdateCustomerFund(customerFund.CustomerID, customerFund.FundID, 1000);

                //////    System.Collections.Generic.List<CustomerFund> lstCustomerFund = AuthenticationSSO.GetCustomerFund(ThisCustomer.CustomerID);
                //////    if (lstCustomerFund.Count > 1)
                //////    {
                //////        foreach (CustomerFund fund in lstCustomerFund)
                //////            fund.Amount = 1000;
                //////        AuthenticationSSO.UpdateCustomerFund(lstCustomerFund);
                //////    }
                //////}

                if (ThisCustomer.IsRegistered)
                {
                    LoginOK = System.Web.Security.Membership.ValidateUser(EMailField, PasswordField);

                    if (LoginOK)
                    {
                        if (ThisCustomer.LockedUntil > DateTime.Now)
                        {
                            ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.3", m_SkinID, ThisCustomer.LocaleSetting);
                            ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true);
                            ErrorPanel.Visible = true;
                            return;
                        }
                        if (!ThisCustomer.Active)
                        {
                            ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.2", m_SkinID, ThisCustomer.LocaleSetting);
                            ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true);
                            ErrorPanel.Visible = true;
                            return;
                        }

                        // Disable Admin Pwd Change Feature
                        //if (((ThisCustomer.IsAdminSuperUser || ThisCustomer.IsAdminUser) && ThisCustomer.PwdChanged.AddDays(AppLogic.AppConfigUSDouble("AdminPwdChangeDays")) < DateTime.Now) || ThisCustomer.PwdChangeRequired)
                        //{
                        //    ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.4", m_SkinID, ThisCustomer.LocaleSetting);
                        //    tbCustomerEmail.Text = ctrlLogin.UserName;
                        //    ExecutePanel.Visible = false;
                        //    pnlForm.Visible = false;
                        //    pnlChangePwd.Visible = true;
                        //    pnlPasswordChangeError.Visible = false;
                        //    ctrlRecoverPassword.Visible = false;
                        //    tbOldPassword.Focus();
                        //    return;
                        //}

                        int NewCustomerID = ThisCustomer.CustomerID;

                        if (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") || AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled"))
                        {
                            //A Registered Customer browse the products in store site not yet logged-in, update the productview with the Customer's CustomerGUID when
                            //later he decided to login
                            ThisCustomer.ReplaceProductViewFromAnonymous();
                        }

                        AppLogic.ExecuteSigninLogic(CurrentCustomerID, NewCustomerID);


                        object affiliateIDParameter = null;

                        // reset the cookie value if present for affiliate
                        int affiliateIDFromCookie = int.Parse(CommonLogic.IIF(CommonLogic.IsInteger(Profile.GetPropertyValue(Customer.ro_AffiliateCookieName).ToString()), Profile.GetPropertyValue(Customer.ro_AffiliateCookieName).ToString(), "0"));

                        if (AppLogic.IsValidAffiliate(affiliateIDFromCookie))
                        {
                            // reset it's value
                            Profile.SetPropertyValue(Customer.ro_AffiliateCookieName, affiliateIDFromCookie.ToString());

                            affiliateIDParameter = affiliateIDFromCookie;
                        }

                        if (ThisCustomer.IsAdminUser)
                        {
                            Security.LogEvent("Store Login", "", ThisCustomer.CustomerID, ThisCustomer.CustomerID, ThisCustomer.ThisCustomerSession.SessionID);
                        }


                        object lockeduntil = DateTime.Now.AddMinutes(-1);
                        ThisCustomer.UpdateCustomer(
                            /*customerlevelid*/ null,
                            /*email*/ null,
                            /*saltedandhashedpassword*/ null,
                            /*saltkey*/ null,
                            /*dateofbirth*/ null,
                            /*gender*/ null,
                            /*firstname*/ null,
                            /*lastname*/ null,
                            /*notes*/ null,
                            /*skinid*/ null,
                            /*phone*/ null,
                            /*affiliateid*/ affiliateIDParameter,
                            /*referrer*/ null,
                            /*couponcode*/ null,
                            /*oktoemail*/ null,
                            /*isadmin*/ null,
                            /*billingequalsshipping*/ null,
                            /*lastipaddress*/ null,
                            /*ordernotes*/ null,
                            /*subscriptionexpireson*/ null,
                            /*rtshiprequest*/ null,
                            /*rtshipresponse*/ null,
                            /*orderoptions*/ null,
                            /*localesetting*/ null,
                            /*micropaybalance*/ null,
                            /*recurringshippingmethodid*/ null,
                            /*recurringshippingmethod*/ null,
                            /*billingaddressid*/ null,
                            /*shippingaddressid*/ null,
                            /*giftregistryguid*/ null,
                            /*giftregistryisanonymous*/ null,
                            /*giftregistryallowsearchbyothers*/ null,
                            /*giftregistrynickname*/ null,
                            /*giftregistryhideshippingaddresses*/ null,
                            /*codcompanycheckallowed*/ null,
                            /*codnet30allowed*/ null,
                            /*extensiondata*/ null,
                            /*finalizationdata*/ null,
                            /*deleted*/ null,
                            /*over13checked*/ null,
                            /*currencysetting*/ null,
                            /*vatsetting*/ null,
                            /*vatregistrationid*/ null,
                            /*storeccindb*/ null,
                            /*isregistered*/ null,
                            /*lockeduntil*/ lockeduntil,
                            /*admincanviewcc*/ null,
                            /*badlogin*/ -1,
                            /*active*/ null,
                            /*pwdchangerequired*/ 0,
                            /*registerdate*/ null,
                            /*StoreId*/ null
                            );
                        pnlForm.Visible      = false;
                        ExecutePanel.Visible = true;


                        String CustomerGUID = ThisCustomer.CustomerGUID.Replace("{", "").Replace("}", "");

                        ExecutePanel.Visible    = true;
                        SignInExecuteLabel.Text = AppLogic.GetString("signin.aspx.2", m_SkinID, ThisCustomer.LocaleSetting);

                        string cookieUserName         = CustomerGUID.ToString();
                        bool   createPersistentCookie = ctrlLogin.RememberMeSet;

                        string sReturnURL = FormsAuthentication.GetRedirectUrl(cookieUserName, createPersistentCookie);
                        FormsAuthentication.SetAuthCookie(cookieUserName, createPersistentCookie);

                        HttpCookie authCookie = Response.Cookies[FormsAuthentication.FormsCookieName];
                        if (authCookie != null && !AppLogic.AppConfigBool("GoNonSecureAgain"))
                        {
                            authCookie.Secure = AppLogic.UseSSL() && AppLogic.OnLiveServer();
                        }

                        if (sReturnURL.Length == 0)
                        {
                            sReturnURL = lblReturnURL.Text;
                        }
                        if (sReturnURL.Length == 0 || sReturnURL == "signin.aspx" || sReturnURL == "/default.aspx")
                        {
                            if (cbDoingCheckout.Checked)
                            {
                                sReturnURL = "~/account.aspx?checkout=true";//checkoutshipping
                            }
                            else
                            {
                                sReturnURL = "~/default.aspx";
                            }
                        }
                        Customer c = new Customer(EMailField, true);
                        if (AppLogic.AppConfigBool("Checkout.RedirectToCartOnSignin"))
                        {
                            ShoppingCart newCart = new ShoppingCart(3, c, CartTypeEnum.ShoppingCart, 0, false);
                            sReturnURL = newCart.PageToBeginCheckout(false, false);
                            if (newCart.Total(true) != cart.Total(true))
                            {
                                ErrorMessage em = new ErrorMessage("checkoutshipping.aspx.25".StringResource());
                                sReturnURL = sReturnURL.AppendQueryString("errormsg=" + em.MessageId);
                            }
                            Response.AddHeader("REFRESH", "1; URL=" + Server.UrlDecode(sReturnURL));
                        }
                        else
                        {
                            Response.AddHeader("REFRESH", "1; URL=" + Server.UrlDecode("shoppingcart.aspx"));
                        }
                        ctrlRecoverPassword.Visible = false;
                        Response.Redirect(sReturnURL);
                    }
                    else
                    {
                        if (AppLogic.AppConfigBool("SecurityCodeRequiredOnStoreLogin"))
                        {
                            tbSecurityCode.Text     = "";
                            Session["SecurityCode"] = CommonLogic.GenerateRandomCode(6);
                        }
                        ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.1", m_SkinID, ThisCustomer.LocaleSetting);
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true);
                        ErrorPanel.Visible = true;
                        if (ThisCustomer.IsAdminUser)
                        {
                            object lockuntil = null;
                            int    badlogin  = 1;
                            if ((ThisCustomer.BadLoginCount + 1) >= AppLogic.AppConfigNativeInt("MaxBadLogins"))
                            {
                                lockuntil          = DateTime.Now.AddMinutes(AppLogic.AppConfigUSInt("BadLoginLockTimeOut"));
                                badlogin           = -1;
                                ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.3", m_SkinID, ThisCustomer.LocaleSetting);
                                ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true);
                                ErrorPanel.Visible = true;
                            }

                            ThisCustomer.UpdateCustomer(
                                /*CustomerLevelID*/ null,
                                /*EMail*/ null,
                                /*SaltedAndHashedPassword*/ null,
                                /*SaltKey*/ null,
                                /*DateOfBirth*/ null,
                                /*Gender*/ null,
                                /*FirstName*/ null,
                                /*LastName*/ null,
                                /*Notes*/ null,
                                /*SkinID*/ null,
                                /*Phone*/ null,
                                /*AffiliateID*/ null,
                                /*Referrer*/ null,
                                /*CouponCode*/ null,
                                /*OkToEmail*/ null,
                                /*IsAdmin*/ null,
                                /*BillingEqualsShipping*/ null,
                                /*LastIPAddress*/ null,
                                /*OrderNotes*/ null,
                                /*SubscriptionExpiresOn*/ null,
                                /*RTShipRequest*/ null,
                                /*RTShipResponse*/ null,
                                /*OrderOptions*/ null,
                                /*LocaleSetting*/ null,
                                /*MicroPayBalance*/ null,
                                /*RecurringShippingMethodID*/ null,
                                /*RecurringShippingMethod*/ null,
                                /*BillingAddressID*/ null,
                                /*ShippingAddressID*/ null,
                                /*GiftRegistryGUID*/ null,
                                /*GiftRegistryIsAnonymous*/ null,
                                /*GiftRegistryAllowSearchByOthers*/ null,
                                /*GiftRegistryNickName*/ null,
                                /*GiftRegistryHideShippingAddresses*/ null,
                                /*CODCompanyCheckAllowed*/ null,
                                /*CODNet30Allowed*/ null,
                                /*ExtensionData*/ null,
                                /*FinalizationData*/ null,
                                /*Deleted*/ null,
                                /*Over13Checked*/ null,
                                /*CurrencySetting*/ null,
                                /*VATSetting*/ null,
                                /*VATRegistrationID*/ null,
                                /*StoreCCInDB*/ null,
                                /*IsRegistered*/ null,
                                /*LockedUntil*/ lockuntil,
                                /*AdminCanViewCC*/ null,
                                /*BadLogin*/ badlogin,
                                /*Active*/ null,
                                /*PwdChangeRequired*/ null,
                                /*RegisterDate*/ null,
                                /*StoreId*/ null
                                );
                        }
                        if (ThisCustomer.IsAdminUser)
                        {
                            Security.LogEvent("Store Login Failed", "Attempted login failed for email address " + EMailField, 0, 0, 0);
                            return;
                        }
                    }
                }
                else
                {
                    ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.1", m_SkinID, ThisCustomer.LocaleSetting);
                    ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true);
                    ErrorPanel.Visible      = true;
                    Session["SecurityCode"] = CommonLogic.GenerateRandomCode(6);
                    tbSecurityCode.Text     = "";
                    return;
                }
            }
        }