예제 #1
0
        public static bool SignIn(string email, string password, bool isHash, bool createPersistentCookie)
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                return(false);
            }

            CustomerContext.IsDebug = Secure.IsDebugAccount(email, password);

            if (CustomerContext.IsDebug)
            {
                Secure.AddUserLog("sa", true, true);
                return(true);
            }

            var oldCustomerId = CustomerContext.CurrentCustomer.Id;
            var customer      = CustomerService.GetCustomerByEmailAndPassword(email, password, isHash);

            if (customer == null)
            {
                return(false);
            }

            Secure.AddUserLog(customer.EMail, true, customer.IsAdmin);
            ShoppingCartService.MergeShoppingCarts(oldCustomerId, customer.Id);
            CustomerContext.SetCustomerCookie(customer.Id);
            FormsAuthentication.SetAuthCookie(email + Spliter + customer.Password, createPersistentCookie);
            return(true);
        }
예제 #2
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);
            }
        }