예제 #1
0
        public void ConfigureMembershipReboot(IServiceCollection services)
        {
            var confg = Configuration.GetSection("membershipReboot");
            var smtp  = Configuration.GetSection("smtp");

            services.Configure <SecuritySettings>(confg);

            var accountConfig = new ApplicationAccountInformation(
                new PathString("/Account/Login/"),
                new PathString("/Account/Activate/"),
                new PathString("/Account/CancelAccountVerification/"),
                new PathString("/Account/ResetPassword/")
                );

            var smtpConfig = new StmpDeliveryConfig
            {
                Host             = smtp["host"],
                Port             = int.Parse(smtp["port"]),
                EnableSsl        = bool.Parse(smtp["enableSsl"]),
                UserName         = Configuration["smtp-username"],
                Password         = Configuration["smtp-password"],
                FromEmailAddress = smtp["fromEmail"]
            };

            services.ConfigureSolutionFormsProviders(accountConfig, smtpConfig);
        }
예제 #2
0
        public static void ConfigureSolutionFormsProviders(this IServiceCollection services, ApplicationAccountInformation appAccountInformation, StmpDeliveryConfig smtpConfig)
        {
            services.AddTransient <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton(p => RavenContext.DocumentStore);
            //services.AddSingleton(p => new MembershipRebootConfiguration<ApplicationUser>(p.GetService<IOptions<SecuritySettings>>().Value));
            services.AddSingleton(p =>
            {
                var contextAccessor = p.GetService <IHttpContextAccessor>();
                var appInfo         = new NewAspNetApplicationInformation(contextAccessor, "Solution Forms", "Solution Forms Team", appAccountInformation.RelativeLoginUrl, appAccountInformation.RelativeConfirmChangeEmailUrl, appAccountInformation.RelativeCancelVerificationUrl, appAccountInformation.RelativeConfirmPasswordResetUrl)
                {
                    CancelVerificationUrl   = appAccountInformation.CancelVerificationUrl,
                    ConfirmChangeEmailUrl   = appAccountInformation.ConfirmChangeEmailUrl,
                    ConfirmPasswordResetUrl = appAccountInformation.ConfirmChangeEmailUrl,
                };
                var config = new MembershipRebootConfiguration <ApplicationUser>(p.GetService <IOptions <SecuritySettings> >().Value);
                //todo: get application URL builder from services and pass into appInfo constructor.
                config.AddEventHandler(new EmailAccountEventsHandler <ApplicationUser>(new EmailMessageFormatter <ApplicationUser>(appInfo), new SmtpMessageDelivery(smtpConfig)));
                return(config);
            });
            services.AddScoped <UserAccountService <ApplicationUser> >();
            services.AddScoped <DataFormsProvider>();
            services.AddScoped <DataSourcesProvider>();
            services.AddScoped <IUserAccountRepository <ApplicationUser>, MembershipProvider>();
            services.AddScoped <AuthenticationService <ApplicationUser> >(provider =>
                                                                          new AspNetAuthenticationService(
                                                                              provider.GetService <UserAccountService <ApplicationUser> >(),
                                                                              provider.GetService <IHttpContextAccessor>().HttpContext));

            services.AddScoped <TenantProvider>();
            services.AddScoped <PaymentProvider>();
        }