Example #1
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);
        }
        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);
                }

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

            return(response);
        }