Esempio n. 1
0
        /// <summary>
        /// This API retrieves a copy of the user data based on the Phone
        /// </summary>
        /// <param name="phoneAuthenticationModel">Model Class containing Definition of payload for PhoneAuthenticationModel API</param>
        /// <param name="fields">The fields parameter filters the API response so that the response only includes a specific set of fields</param>
        /// <param name="loginUrl">Url where the user is logging from</param>
        /// <param name="smsTemplate">SMS Template name</param>
        /// <returns>Response containing User Profile Data and access token</returns>
        /// 9.2.3

        public ApiResponse <AccessToken <Identity> > LoginByPhone(PhoneAuthenticationModel phoneAuthenticationModel, string fields = "",
                                                                  string loginUrl = null, string smsTemplate = null)
        {
            if (phoneAuthenticationModel == null)
            {
                throw new ArgumentException(BaseConstants.ValidationMessage, nameof(phoneAuthenticationModel));
            }
            var queryParameters = new QueryParameters
            {
                { "apiKey", ConfigDictionary[LRConfigConstants.LoginRadiusApiKey] }
            };

            if (!string.IsNullOrWhiteSpace(fields))
            {
                queryParameters.Add("fields", fields);
            }
            if (!string.IsNullOrWhiteSpace(loginUrl))
            {
                queryParameters.Add("loginUrl", loginUrl);
            }
            if (!string.IsNullOrWhiteSpace(smsTemplate))
            {
                queryParameters.Add("smsTemplate", smsTemplate);
            }

            var resourcePath = "identity/v2/auth/login";

            return(ConfigureAndExecute <AccessToken <Identity> >(HttpMethod.POST, resourcePath, queryParameters, ConvertToJson(phoneAuthenticationModel)));
        }
Esempio n. 2
0
        public static bool CheckAuthentication(PhoneAuthenticationModel credentials)
        {
            if (credentials == null)
            {
                return(false);
            }

            if (credentials.IMEI != null && credentials.SecToken != null)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        public string GetMask([FromBody] PhoneAuthenticationModel credentials)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["SilentConnection"].ConnectionString;

            return(Base64Helper.Encode(SqlHelper.GetMask(connectionString, Base64Helper.Decode(credentials.IMEI), Base64Helper.Decode(credentials.SecToken))));
        }
Esempio n. 4
0
        /// <summary>
        /// This API retrieves a copy of the user data based on the Phone
        /// </summary>
        /// <param name="phoneAuthenticationModel">Model Class containing Definition of payload for PhoneAuthenticationModel API</param>
        /// <param name="emailTemplate">Email template name</param>
        /// <param name="fields">The fields parameter filters the API response so that the response only includes a specific set of fields</param>
        /// <param name="loginUrl">Url where the user is logging from</param>
        /// <param name="passwordDelegation">Password Delegation Allows you to use a third-party service to store your passwords rather than LoginRadius Cloud storage.</param>
        /// <param name="passwordDelegationApp">RiskBased Authentication Password Delegation App</param>
        /// <param name="rbaBrowserEmailTemplate">Risk Based Authentication Browser EmailTemplate</param>
        /// <param name="rbaBrowserSmsTemplate">Risk Based Authentication Browser Sms Template</param>
        /// <param name="rbaCityEmailTemplate">Risk Based Authentication City Email Template</param>
        /// <param name="rbaCitySmsTemplate">Risk Based Authentication City SmsTemplate</param>
        /// <param name="rbaCountryEmailTemplate">Risk Based Authentication Country EmailTemplate</param>
        /// <param name="rbaCountrySmsTemplate">Risk Based Authentication Country SmsTemplate</param>
        /// <param name="rbaIpEmailTemplate">Risk Based Authentication Ip EmailTemplate</param>
        /// <param name="rbaIpSmsTemplate">Risk Based Authentication Ip SmsTemplate</param>
        /// <param name="rbaOneclickEmailTemplate">Risk Based Authentication Oneclick EmailTemplate</param>
        /// <param name="rbaOTPSmsTemplate">Risk Based Authentication OTPSmsTemplate</param>
        /// <param name="smsTemplate">SMS Template name</param>
        /// <param name="verificationUrl">Email verification url</param>
        /// <returns>Response containing User Profile Data and access token</returns>
        /// 9.2.6

        public ApiResponse <AccessToken <Identity> > RBALoginByPhone(PhoneAuthenticationModel phoneAuthenticationModel, string emailTemplate = null,
                                                                     string fields = "", string loginUrl = null, bool?passwordDelegation = null, string passwordDelegationApp = null, string rbaBrowserEmailTemplate = null,
                                                                     string rbaBrowserSmsTemplate = null, string rbaCityEmailTemplate = null, string rbaCitySmsTemplate = null, string rbaCountryEmailTemplate  = null,
                                                                     string rbaCountrySmsTemplate = null, string rbaIpEmailTemplate   = null, string rbaIpSmsTemplate   = null, string rbaOneclickEmailTemplate = null,
                                                                     string rbaOTPSmsTemplate     = null, string smsTemplate = null, string verificationUrl = null)
        {
            if (phoneAuthenticationModel == null)
            {
                throw new ArgumentException(BaseConstants.ValidationMessage, nameof(phoneAuthenticationModel));
            }
            var queryParameters = new QueryParameters
            {
                { "apiKey", ConfigDictionary[LRConfigConstants.LoginRadiusApiKey] }
            };

            if (!string.IsNullOrWhiteSpace(emailTemplate))
            {
                queryParameters.Add("emailTemplate", emailTemplate);
            }
            if (!string.IsNullOrWhiteSpace(fields))
            {
                queryParameters.Add("fields", fields);
            }
            if (!string.IsNullOrWhiteSpace(loginUrl))
            {
                queryParameters.Add("loginUrl", loginUrl);
            }
            if (passwordDelegation != false)
            {
                queryParameters.Add("passwordDelegation", passwordDelegation.ToString());
            }
            if (!string.IsNullOrWhiteSpace(passwordDelegationApp))
            {
                queryParameters.Add("passwordDelegationApp", passwordDelegationApp);
            }
            if (!string.IsNullOrWhiteSpace(rbaBrowserEmailTemplate))
            {
                queryParameters.Add("rbaBrowserEmailTemplate", rbaBrowserEmailTemplate);
            }
            if (!string.IsNullOrWhiteSpace(rbaBrowserSmsTemplate))
            {
                queryParameters.Add("rbaBrowserSmsTemplate", rbaBrowserSmsTemplate);
            }
            if (!string.IsNullOrWhiteSpace(rbaCityEmailTemplate))
            {
                queryParameters.Add("rbaCityEmailTemplate", rbaCityEmailTemplate);
            }
            if (!string.IsNullOrWhiteSpace(rbaCitySmsTemplate))
            {
                queryParameters.Add("rbaCitySmsTemplate", rbaCitySmsTemplate);
            }
            if (!string.IsNullOrWhiteSpace(rbaCountryEmailTemplate))
            {
                queryParameters.Add("rbaCountryEmailTemplate", rbaCountryEmailTemplate);
            }
            if (!string.IsNullOrWhiteSpace(rbaCountrySmsTemplate))
            {
                queryParameters.Add("rbaCountrySmsTemplate", rbaCountrySmsTemplate);
            }
            if (!string.IsNullOrWhiteSpace(rbaIpEmailTemplate))
            {
                queryParameters.Add("rbaIpEmailTemplate", rbaIpEmailTemplate);
            }
            if (!string.IsNullOrWhiteSpace(rbaIpSmsTemplate))
            {
                queryParameters.Add("rbaIpSmsTemplate", rbaIpSmsTemplate);
            }
            if (!string.IsNullOrWhiteSpace(rbaOneclickEmailTemplate))
            {
                queryParameters.Add("rbaOneclickEmailTemplate", rbaOneclickEmailTemplate);
            }
            if (!string.IsNullOrWhiteSpace(rbaOTPSmsTemplate))
            {
                queryParameters.Add("rbaOTPSmsTemplate", rbaOTPSmsTemplate);
            }
            if (!string.IsNullOrWhiteSpace(smsTemplate))
            {
                queryParameters.Add("smsTemplate", smsTemplate);
            }
            if (!string.IsNullOrWhiteSpace(verificationUrl))
            {
                queryParameters.Add("verificationUrl", verificationUrl);
            }

            var resourcePath = "identity/v2/auth/login";

            return(ConfigureAndExecute <AccessToken <Identity> >(HttpMethod.POST, resourcePath, queryParameters, ConvertToJson(phoneAuthenticationModel)));
        }