コード例 #1
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);
            }
        }