Esempio n. 1
0
        public async Task <AutoCareUser> GetUserAsync(string username, string password)
        {
            serviceSoap  proxy        = null;
            AutoCareUser autoCareUser = null;

            try
            {
                proxy = _personifySsoServiceProxy ?? GetSsoServiceProxy();

                var customerAuth = proxy.CustomerAuthenticateAndGetId(_personifyConfiguration.VendorUserName,
                                                                      _personifyConfiguration.VendorPassword, username, password);

                autoCareUser = new AutoCareUser(customerAuth.CustomerId);

                var customerDetail = await proxy.SSOCustomerGetAsync(_personifyConfiguration.VendorUserName, _personifyConfiguration.VendorPassword,
                                                                     autoCareUser.Id);

                autoCareUser.UserName = customerDetail.UserName;
                autoCareUser.Email    = customerDetail.Email;

                autoCareUser.CustomerToken = await GetCustomerTokenAsync(username, password);
            }
            finally
            {
                CloseProxy(proxy);
            }

            return(autoCareUser);
        }
Esempio n. 2
0
 public PersonifyHelper(PersonifyConfiguration personifyConfiguration = null,
                        serviceSoap personifySsoServiceProxy          = null,
                        IMServiceSoap personifyImsServiceProxy        = null)
 {
     _personifyConfiguration   = personifyConfiguration ?? new PersonifyConfiguration();
     _personifySsoServiceProxy = personifySsoServiceProxy;
     _personifyImsServiceProxy = personifyImsServiceProxy;
 }
Esempio n. 3
0
        public async Task <string> GetCustomerTokenAsync(string username, string password)
        {
            serviceSoap proxy         = null;
            string      customerToken = null;

            try
            {
                proxy = _personifySsoServiceProxy ?? GetSsoServiceProxy();
                var url  = HttpContext.Current.Request.Url;
                var port = url.Port != 80 ? (":" + url.Port) : String.Empty;

                var callbackUrl = $"{url.Scheme}://{url.Host}{port}/";
                var redirectUrl =
                    SSOLoginManager.ConstructSSOURLForAutoLogin(_personifyConfiguration.SsoLoginUrl,
                                                                callbackUrl, username, password, true);
                //The url could be local host even for production environment because it doesn't matter which domain we use.
                //All we do is to get CustomerToken from query string

                WebRequest request = WebRequest.Create(redirectUrl);
                request.Method = "GET";
                WebResponse response = await request.GetResponseAsync();

                if (!String.IsNullOrWhiteSpace(response.ResponseUri.Query))
                {
                    customerToken = HttpUtility.ParseQueryString(response.ResponseUri.Query)["ct"];
                }

                response.Close();
            }
            finally
            {
                CloseProxy(proxy);
            }

            return(customerToken);
        }