public IHttpActionResult EmailExists(int userId, string email) { //TODO let's clean this up var authorizedWithCookie = Authorized(t => { var exists = _lookupRepository.EmailSearch(email, t); if (exists.Count == 0 || Convert.ToInt32(exists["dp_RecordID"]) == userId) { return(Ok()); } return(BadRequest()); }); if (authorizedWithCookie is UnauthorizedResult) { var apiUser = _configurationWrapper.GetEnvironmentVarAsString("API_USER"); var apiPassword = _configurationWrapper.GetEnvironmentVarAsString("API_PASSWORD"); var authData = AuthenticationRepository.authenticate(apiUser, apiPassword); var token = authData["token"].ToString(); var exists = _lookupRepository.EmailSearch(email, token.ToString()); if (exists.Count == 0) { return(Ok()); } return(BadRequest()); } return(authorizedWithCookie); }
public IHttpActionResult EmailExists(int userId, string email) { //the userId parameter really contains the contact id //TODO let's clean this up var authorizedWithCookie = Authorized(t => { var exists = _lookupRepository.EmailSearch(email, t); if (exists.Count == 0 || _userService.GetContactIdByUserId(Convert.ToInt32(exists["dp_RecordID"])) == userId) { return(Ok()); } return(BadRequest()); }); if (authorizedWithCookie is UnauthorizedResult) { var apiUser = _configurationWrapper.GetEnvironmentVarAsString("API_USER"); var apiPassword = _configurationWrapper.GetEnvironmentVarAsString("API_PASSWORD"); var authData = _authenticationRepository.Authenticate(apiUser, apiPassword); var token = authData?.AccessToken; var exists = _lookupRepository.EmailSearch(email, token); if (exists.Count == 0) { return(Ok()); } return(BadRequest()); } return(authorizedWithCookie); }
protected string ApiLogin() { var apiUser = _configurationWrapper.GetEnvironmentVarAsString("API_USER"); var apiPasword = _configurationWrapper.GetEnvironmentVarAsString("API_PASSWORD"); var authData = _authenticationService.Authenticate(apiUser, apiPasword); var token = authData["token"].ToString(); return(token); }
public AwsCloudsearchService(IAddressGeocodingService addressGeocodingService, IFinderRepository finderRepository, IConfigurationWrapper configurationWrapper) { _addressGeocodingService = addressGeocodingService; _finderRepository = finderRepository; _configurationWrapper = configurationWrapper; AmazonSearchUrl = _configurationWrapper.GetEnvironmentVarAsString("CRDS_AWS_CONNECT_ENDPOINT"); AwsAccessKeyId = _configurationWrapper.GetEnvironmentVarAsString("CRDS_AWS_CONNECT_ACCESSKEYID"); AwsSecretAccessKey = _configurationWrapper.GetEnvironmentVarAsString("CRDS_AWS_CONNECT_SECRETACCESSKEY"); }
public TwilioService(IConfigurationWrapper configurationWrapper) { var accountSid = configurationWrapper.GetConfigValue("TwilioAccountSid"); var authToken = configurationWrapper.GetEnvironmentVarAsString("TWILIO_AUTH_TOKEN"); _fromPhoneNumber = configurationWrapper.GetConfigValue("TwilioFromPhoneNumber"); _twilio = new TwilioRestClient(accountSid, authToken); }
private RestClient GetBulkEmailClient() { var apiUrl = _configWrapper.GetConfigValue("BulkEmailApiUrl"); var apiKey = _configWrapper.GetEnvironmentVarAsString("BULK_EMAIL_API_KEY"); var client = new RestClient(apiUrl); client.Authenticator = new HttpBasicAuthenticator("noname", apiKey); return(client); }
public StripePaymentProcessorService(IRestClient stripeRestClient, IConfigurationWrapper configuration, IContentBlockService contentBlockService) { _stripeRestClient = stripeRestClient; _maxQueryResultsPerPage = configuration.GetConfigIntValue("MaxStripeQueryResultsPerPage"); var stripeApiVersion = configuration.GetEnvironmentVarAsString("CRDS_STRIPE_API_VERSION", false); if (stripeApiVersion != null) { _stripeRestClient.AddDefaultHeader("Stripe-Version", stripeApiVersion); } _contentBlockService = contentBlockService; }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { return(configurationWrapper.GetEnvironmentVarAsString((string)value)); }