Esempio n. 1
0
        /// <summary>
        /// Generate default clients, identity and api resources
        /// </summary>
        private static async Task EnsureSeedIdentityServerData(ApplicationSsoContext context, IConfiguration configuration)
        {
            if (!context.Clients.Any())
            {
                foreach (var client in Clients.GetAdminClient(configuration).ToList())
                {
                    await context.Clients.AddAsync(client.ToEntity());
                }

                await context.SaveChangesAsync();
            }

            if (!context.IdentityResources.Any())
            {
                var identityResources = ClientResources.GetIdentityResources().ToList();

                foreach (var resource in identityResources)
                {
                    await context.IdentityResources.AddAsync(resource.ToEntity());
                }

                await context.SaveChangesAsync();
            }

            if (!context.ApiResources.Any())
            {
                foreach (var resource in ClientResources.GetApiResources().ToList())
                {
                    await context.ApiResources.AddAsync(resource.ToEntity());
                }

                await context.SaveChangesAsync();
            }
        }
Esempio n. 2
0
        public UserAppServiceInMemoryTests(WarmupInMemory inMemory)
        {
            _faker                 = new Faker();
            InMemoryData           = inMemory;
            _userAppService        = InMemoryData.Services.GetRequiredService <IUserAppService>();
            _userManagerAppService = InMemoryData.Services.GetRequiredService <IUserManageAppService>();
            _database              = InMemoryData.Services.GetRequiredService <ApplicationSsoContext>();
            var notifications = (DomainNotificationHandler)InMemoryData.Services.GetRequiredService <INotificationHandler <DomainNotification> >();

            notifications.Clear();
        }
Esempio n. 3
0
        public EmailAppServiceInMemoryTests(WarmupInMemory inMemory, ITestOutputHelper output)
        {
            _output          = output;
            _faker           = new Faker();
            InMemoryData     = inMemory;
            _emailAppService = InMemoryData.Services.GetRequiredService <IEmailAppService>();
            _database        = InMemoryData.Services.GetRequiredService <ApplicationSsoContext>();
            _notifications   = (DomainNotificationHandler)InMemoryData.Services.GetRequiredService <INotificationHandler <DomainNotification> >();

            _notifications.Clear();
        }
Esempio n. 4
0
        public GlobalSettingsTests(WarmupInMemory inMemory, ITestOutputHelper output)
        {
            _output           = output;
            _faker            = new Faker();
            InMemoryData      = inMemory;
            _globalAppService = InMemoryData.Services.GetRequiredService <IGlobalConfigurationAppService>();
            _database         = InMemoryData.Services.GetRequiredService <ApplicationSsoContext>();

            _user           = (AspNetUserTest)InMemoryData.Services.GetService <ISystemUser>();
            _user._isInRole = true;
            _notifications  = (DomainNotificationHandler)InMemoryData.Services.GetRequiredService <INotificationHandler <DomainNotification> >();

            _notifications.Clear();
        }
Esempio n. 5
0
        private static async Task EnsureSeedGlobalConfigurationData(ApplicationSsoContext context,
                                                                    IConfiguration configuration, IWebHostEnvironment env)
        {
            if (!context.GlobalConfigurationSettings.Any())
            {
                await context.GlobalConfigurationSettings.AddAsync(new GlobalConfigurationSettings("Smtp:Server", configuration.GetSection("EmailConfiguration:SmtpServer").Value, false, false));

                await context.GlobalConfigurationSettings.AddAsync(new GlobalConfigurationSettings("Smtp:Port", configuration.GetSection("EmailConfiguration:SmtpPort").Value, false, false));

                await context.GlobalConfigurationSettings.AddAsync(new GlobalConfigurationSettings("Smtp:UseSsl", configuration.GetSection("EmailConfiguration:UseSsl").Value, false, false));

                await context.GlobalConfigurationSettings.AddAsync(new GlobalConfigurationSettings("Smtp:Username", configuration.GetSection("EmailConfiguration:SmtpUsername").Value, true, false));

                await context.GlobalConfigurationSettings.AddAsync(new GlobalConfigurationSettings("Smtp:Password", configuration.GetSection("EmailConfiguration:SmtpPassword").Value, true, false));

                await context.GlobalConfigurationSettings.AddAsync(new GlobalConfigurationSettings("SendEmail", configuration.GetSection("EmailConfiguration:SendEmail").Value, false, false));

                await context.SaveChangesAsync();
            }

            if (!context.Emails.Any())
            {
                var newUserEmail       = File.ReadAllText(Path.Combine(env.ContentRootPath, @"Assets/templates/new-user-email.html"));
                var resetPasswordEmail = File.ReadAllText(Path.Combine(env.ContentRootPath, @"Assets/templates/reset-password-email.html"));
                var template           = File.ReadAllText(Path.Combine(env.ContentRootPath, @"Assets/templates/default-template.html"));

                await context.Emails.AddAsync(new Email(newUserEmail, "Welcome to JP Project - Confirm your e-mail", new Sender("*****@*****.**", "JP Team"), EmailType.NewUser, null));

                await context.Emails.AddAsync(new Email(newUserEmail, "Welcome to JP Project - Confirm your e-mail", new Sender("*****@*****.**", "JP Team"), EmailType.NewUserWithoutPassword, null));

                await context.Emails.AddAsync(new Email(resetPasswordEmail, "JP Project - Reset Password", new Sender("*****@*****.**", "JP Team"), EmailType.RecoverPassword, null));

                await context.Templates.AddRangeAsync(new Template(template, "JP Team", "default-template", Users.GetEmail(configuration)));

                await context.SaveChangesAsync();
            }
        }
 public GlobalConfigurationSettingsRepository(ApplicationSsoContext context) : base(context)
 {
 }
Esempio n. 7
0
 public UnitOfWork(ApplicationSsoContext context)
 {
     _context = context;
 }
Esempio n. 8
0
 public EmailRepository(ApplicationSsoContext context) : base(context)
 {
 }
 public Repository(ApplicationSsoContext context)
 {
     Db    = context;
     DbSet = Db.Set <TEntity>();
 }