Esempio n. 1
0
        /// <summary>
        /// Adds the hCAPTCHA middleware to the services collection.
        /// </summary>
        /// <param name="services">Contains the services collection to add the provider to.</param>
        /// <param name="section">Contains a configuration section containing CAPTCHA options.</param>
        /// <returns>Returns the modified services collection.</returns>
        public static IServiceCollection AddHCaptcha(this IServiceCollection services, IConfigurationSection section)
        {
            CaptchaOptions captchaOptions = section.Get <CaptchaOptions>();

            return(services.AddHCaptcha(captchaOptions));
        }
Esempio n. 2
0
        //// <summary>
        /// Adds the hCAPTCHA middleware to the services collection.
        /// </summary>
        /// <param name="services">Contains the services collection to add the provider to.</param>
        /// <param name="options">Contains the options.</param>
        /// <returns>Returns the modified services collection.</returns>
        public static IServiceCollection AddHCaptcha(this IServiceCollection services, CaptchaOptions options)
        {
            // register the Refit REST calls client
            services.AddRefitClient <IHCaptchaApi>().ConfigureHttpClient(c =>
            {
                c.BaseAddress = options.ApiBaseUrl;
            });

            services.AddScoped((s) => { return(options); });
            services.AddScoped <IHCaptchaProvider, HCaptchaProvider>();

            return(services);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="HCaptchaModelBinder" /> class.
 /// </summary>
 /// <param name="captchaProvider">The captcha provider.</param>
 /// <param name="options">The options.</param>
 public HCaptchaModelBinder(IHCaptchaProvider captchaProvider, CaptchaOptions options)
 {
     this.captchaProvider = captchaProvider;
     this.options         = options;
 }