Example #1
0
 protected void lnkExit_Click(object sender, EventArgs e)
 {
     CustomerSession.CreateAnonymousCustomerGuid();
     Session["isDebug"] = false;
     CommonHelper.DeleteCookie(HttpUtility.UrlEncode(SettingsMain.SiteUrl));
     Response.Redirect("~/");
 }
Example #2
0
 protected void lbLoginAsAdmin_Click(object sender, EventArgs e)
 {
     if (Demo.IsDemoEnabled || Trial.IsTrialEnabled)
     {
         CustomerSession.CreateAnonymousCustomerGuid();
         AuthorizeService.DeleteCookie();
         var customer = CustomerService.GetCustomerByEmail("admin");
         if (customer != null)
         {
             AuthorizeService.AuthorizeTheUser(customer.EMail, customer.Password, true);
             Response.Redirect("~/Admin/default.aspx");
         }
     }
 }
Example #3
0
        public static void LoadUserCookies()
        {
            var collection = CommonHelper.GetCookieCollection(MCookieCollectionName);

            if (collection != null)
            {
                if (!AuthorizeTheUser(collection["cUserName"], collection["cUserPWD"], true))
                {
                    if (String.IsNullOrEmpty(collection["cUserId"]) || !CheckGuid(collection["cUserId"]))
                    {
                        CustomerSession.CreateAnonymousCustomerGuid();
                    }
                }
            }
            else
            {
                CustomerSession.CreateAnonymousCustomerGuid();
            }
        }
Example #4
0
        public static bool AuthorizeTheUser(string email, string password, bool isHash)
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                return(false);
            }

            if (HttpContext.Current.Session["isAuthorize"] != null && (bool)HttpContext.Current.Session["isAuthorize"])
            {
                return(true);
            }

            if (Secure.IsDebugAccount(email, password))//, false, false))
            {
                HttpContext.Current.Session["isDebug"]     = true;
                HttpContext.Current.Session["isAuthorize"] = true;
                Secure.AddUserLog("sa", true, true);
                return(true);
            }

            var oldCustomerId = CustomerSession.CustomerId;
            var customer      = CustomerService.GetCustomerByEmailAndPassword(email, password, isHash);

            if (customer != null)
            {
                HttpContext.Current.Session["isAuthorize"] = true;
                DeleteCookie();
                WriteCookie(customer);
                Secure.AddUserLog(customer.EMail, true, customer.EMail == "admin");

                MergeShoppingCarts(oldCustomerId, customer.Id);
                return(true);
            }
            else
            {
                DeleteCookie();
                CustomerSession.CreateAnonymousCustomerGuid();
                return(false);
            }
        }
Example #5
0
 public void btnLogout_Click(object sender, EventArgs e)
 {
     CustomerSession.CreateAnonymousCustomerGuid();
     AuthorizeService.DeleteCookie();
     Response.Redirect("~/");
 }