Пример #1
0
        public LoginResponse SignIn(string silentLoginToken)
        {
            var response = new LoginResponse();

            try
            {
                // Decrypt the token
                var token = Security.Decrypt(silentLoginToken);

                // Split the value and get the values

                // Return the expiration status of the token and the sign in response
                if (token.ExpirationDate < DateTime.Now)
                {
                    response.Fail("Token expired");
                    return(response);
                }

                // Sign the customer in with their customer ID
                response = SignIn((int)token.CustomerID);

                // Mark the response as successful
                response.Success();
            }
            catch (Exception ex)
            {
                response.Fail(ex.Message);
            }

            return(response);
        }
Пример #2
0
        public LoginResponse SignIn(string loginname, string password)
        {
            var response = new LoginResponse();

            try
            {
                // Authenticate the customer
                var authenticateUserResponse = Exigo.WebService().AuthenticateUser(new AuthenticateUserRequest
                {
                    LoginName = loginname,
                    Password  = password
                });

                if (authenticateUserResponse.Result.Status == ResultStatus.Failure)
                {
                    response.Fail("Unable to authenticate");
                    return(response);
                }

                CreateFormsAuthenticationTicket(loginname, authenticateUserResponse);


                // Mark the response as successful
                response.Success();
            }
            catch (Exception ex)
            {
                response.Fail(ex.Message);
            }

            return(response);
        }
Пример #3
0
        public LoginResponse SignIn(string loginname, string password)
        {
            var response   = new LoginResponse();
            int customerID = 0;

            try
            {
                // Authenticate the customer
                customerID = authProvider.AuthenticateCustomer(loginname, password);
                if (customerID == 0)
                {
                    response.Fail("Unable to authenticate");
                    return(response);
                }

                // Get the customer

                var identity = GetIdentity(customerID);
                if (identity == null)
                {
                    response.Fail("Customer not found");
                    return(response);
                }

                // Get the redirect URL (for silent logins) or create the forms ticket
                response.RedirectUrl = GetSilentLoginRedirect(identity);

                if (response.RedirectUrl.IsEmpty())
                {
                    CreateFormsAuthenticationTicket(customerID);
                }

                // Mark the response as successful
                response.Success();
            }

            catch (Exception ex)
            {
                response.Fail(ex.Message);
            }
            // 3/09/17 #85791 Brian Bruneau Using customer ID, validate that no crucial customer info is missing (ex. Main Country)
            KeyValuePair <bool, List <string> > identityValidationResponse = Common.Utilities.Identity.IdentityCheck(customerID);

            // 3/09/17 #85791 Brian Bruneau if the customer is not validated, display toastr message and do not authorize login.
            if (!identityValidationResponse.Key)
            {
                response.Fail("Your profile is missing the following: <br> " + "<ol> <li>" + string.Join(" </li><li> ", identityValidationResponse.Value.ToArray()) + "</li></ol>" + "</br> <b>Please contact your administrator for assistance.</b>");
                FormsAuthentication.SignOut();
            }

            return(response);
        }
        // Customer Identities
        public LoginResponse SignIn(string loginname, string password)
        {
            var response = new LoginResponse();

            try
            {
                // Authenticate the customer
                var customerID = _authProvider.AuthenticateCustomer(loginname, password);
                if (customerID == 0)
                {
                    response.Fail("Unable to authenticate");
                    return(response);
                }

                // Get the customer
                var identity = GetIdentity(customerID);
                if (identity == null)
                {
                    if (identity == null)
                    {
                        response.Fail("Customer not found");
                        return(response);
                    }
                }

                // Get the redirect URL (for silent logins) or create the forms ticket
                response.RedirectUrl = GetSilentLoginRedirect(identity);
                if (response.RedirectUrl.IsEmpty())
                {
                    CreateFormsAuthenticationTicket(customerID);
                }

                // Handle updating/clearing the shopping property bags
                UpdateShoppingCartPropertyBags(identity);

                // Mark the response as successful
                response.Success();
            }
            catch (Exception ex)
            {
                response.Fail(ex.Message);
            }

            return(response);
        }
Пример #5
0
        public LoginResponse SignIn(int customerid)
        {
            var response = new LoginResponse();

            try
            {
                // Authenticate the customer
                var customerID = authProvider.AuthenticateCustomer(customerid);
                if (customerID == 0)
                {
                    response.Fail("Unable to authenticate");
                    return(response);
                }

                // Get the customer
                var identity = GetIdentity(customerID);
                if (identity == null)
                {
                    response.Fail("Customer not found");
                    return(response);
                }

                // Get the redirect URL (for silent logins) or create the forms ticket
                response.RedirectUrl = GetSilentLoginRedirect(identity);
                if (response.RedirectUrl.IsEmpty())
                {
                    CreateFormsAuthenticationTicket(customerID);
                }

                // Mark the response as successful
                response.Success();
            }
            catch (Exception ex)
            {
                response.Fail(ex.Message);
            }

            return(response);
        }
        public LoginResponse SignIn(int customerid)
        {
            var response = new LoginResponse();

            try
            {
                // Authenticate the customer
                var customerID = authProvider.AuthenticateCustomer(customerid);
                if (customerID == 0)
                {
                    response.Fail("Unable to authenticate");
                    return(response);
                }

                return(AuthorizeCustomer(customerID));
            }
            catch (Exception ex)
            {
                response.Fail(ex.Message);
            }

            return(response);
        }
Пример #7
0
        public LoginResponse AdminSilentLogin(string token)
        {
            var response = new LoginResponse();

            try
            {
                // Decrypt the token
                var IV             = GlobalSettings.EncryptionKeys.SilentLogins.IV;
                var key            = GlobalSettings.EncryptionKeys.SilentLogins.Key;
                var decryptedToken = Security.AESDecrypt(token, key, IV);

                // Split the value and get the values
                var splitToken          = decryptedToken.Split('|');
                var customerID          = Convert.ToInt32(splitToken[0]);
                var tokenExpirationDate = Convert.ToDateTime(splitToken[1]);

                // Return the expiration status of the token and the sign in response
                //if (tokenExpirationDate < DateTime.Now)
                //{
                //    response.Fail("Token expired");
                //    return response;
                //}

                // Sign the customer in with their customer ID
                response = SignIn(customerID);

                // Mark the response as successful
                response.Success();
            }
            catch (Exception ex)
            {
                response.Fail(ex.Message);
            }

            return(response);
        }