public ReCaptchaClientFacade(ReCaptchaClientSettings settings)
 {
     this.responseBuilder    = new ReCaptchaResponseBuilder();
     this.verificationClient = new ReCaptchaVerificationClient();
     this.clientSettings     = settings;
     if (settings.IsUsingHttpClient)
     {
         this.httpClient = settings.httpClient;
     }
 }
 public ReCaptchaService(IGoogleReCaptchaClient reCaptchaClient)
 {
     _reCaptchaClient         = reCaptchaClient;
     _reCaptchaClientSettings = new ReCaptchaClientSettings()
     {
         IsRecaptchaUsed         = true,
         ReCaptchaCachingTimeout = 30,
         SiteKey   = "[site key here]",
         SecretKey = "[secret key here]"
     };
 }
Example #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            string cs = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <KofCDbContext>(opts => opts.UseMySql(cs));

            services.AddDefaultIdentity <IdentityUser>(options =>
            {
                options.SignIn.RequireConfirmedAccount = true;
                options.SignIn.RequireConfirmedEmail   = true;
            }).AddEntityFrameworkStores <KofCDbContext>();

            services.Configure <DataProtectionTokenProviderOptions>(o => o.TokenLifespan = TimeSpan.FromHours(3));

            services.AddScoped(typeof(IKofCRepository <Contact>), typeof(KofCRepository <Contact>));
            services.AddScoped(typeof(IKofCRepository <ContactType>), typeof(KofCRepository <ContactType>));
            services.AddScoped(typeof(IKofCRepository <ContactAddress>), typeof(KofCRepository <ContactAddress>));
            services.AddScoped(typeof(IKofCRepository <Album>), typeof(KofCRepository <Album>));
            services.AddScoped(typeof(IKofCRepository <AlbumImage>), typeof(KofCRepository <AlbumImage>));
            services.AddScoped(typeof(IKofCRepository <Request>), typeof(KofCRepository <Request>));
            services.AddScoped(typeof(IKofCRepository <Event>), typeof(KofCRepository <Event>));
            services.AddScoped(typeof(IKofCRepository <UploadedFile>), typeof(KofCRepository <UploadedFile>));
            services.AddScoped(typeof(IKofCRepository <NewsItem>), typeof(KofCRepository <NewsItem>));

            services.AddScoped <IEventsRepository, EventsRepository>();
            services.AddScoped <IContactsService, ContactsService>();
            services.AddScoped <IAlbumsService, AlbumsService>();
            services.AddScoped <IRequestsService, RequestsService>();
            services.AddScoped <IImagesService, ImagesService>();
            services.AddScoped <IEventsService, EventsService>();
            services.AddScoped <INewslettersService, NewslettersService>();
            services.AddScoped <INewsItemsService, NewsItemsService>();

            services.AddTransient <IEmailSender, EmailSender>();
            services.Configure <EmailSenderOptions>(Configuration.GetSection("EmailSenderOptions"));

            services.AddScoped <IGoogleReCaptchaClient, GoogleReCaptchaClient>();
            services.AddScoped <IReCaptchaService, ReCaptchaService>();
            services.AddScoped <ReCaptchaClientSettings>(opt =>
            {
                ReCaptchaClientSettings cfg = new ReCaptchaClientSettings();
                Configuration.GetSection("ReCaptchaSettings").Bind(cfg);
                return(cfg);
            });

            services.AddControllersWithViews();
            services.AddMvc();
            //services.AddRazorPages();
        }