Example #1
0
        public virtual async Task <TUser> FindByEmailAsync(string email)
        {
            ThrowIfDisposed();
            IUserEmailStore <TUser> emailStore = GetEmailStore();

            if (email == null)
            {
                throw new ArgumentNullException(nameof(email));
            }

            TUser user = await emailStore.FindByEmailAsync(email, CancellationToken);

            if (user == null && Options.Stores.ProtectPersonalData)
            {
                ILookupProtectorKeyRing keyRing   = _services.GetService <ILookupProtectorKeyRing>();
                ILookupProtector        protector = _services.GetService <ILookupProtector>();
                if (keyRing != null && protector != null)
                {
                    foreach (var key in keyRing.GetAllKeyIds())
                    {
                        string oldKey = protector.Protect(key, email);
                        user = await emailStore.FindByEmailAsync(oldKey, CancellationToken);

                        if (user != null)
                        {
                            return(user);
                        }
                    }
                }
            }
            return(user);
        }
Example #2
0
 public AccountController
 (
     IAuthenticationSchemeProvider schemeProvider,
     ILookupNormalizer keyNormalizer,
     IPasswordValidator passwordValidator,
     IEmailSender emailSender,
     SignInManager <User> signInManager,
     UserManager <User> userManager,
     IIdentityServerInteractionService interaction,
     IEventService events,
     IClientStore clients,
     IUserStore <User> userStore,
     IUserEmailStore <User> userEmailStore
 )
 {
     SchemeProvider    = schemeProvider;
     KeyNormalizer     = keyNormalizer;
     PasswordValidator = passwordValidator;
     EmailSender       = emailSender;
     SignInManager     = signInManager;
     UserManager       = userManager;
     Interaction       = interaction;
     Events            = events;
     Clients           = clients;
     UserStore         = userStore;
     UserEmailStore    = userEmailStore;
 }
Example #3
0
 public UserProvisioner(IUserStore <User> userStore, IUserEmailStore <User> userEmailStore, IUserLoginStore <User> userLoginStore, ILookupNormalizer lookupNormalizer)
     : base()
 {
     UserStore        = userStore;
     UserEmailStore   = userEmailStore;
     UserLoginStore   = userLoginStore;
     LookupNormalizer = lookupNormalizer;
 }
Example #4
0
 public UserfyUserRegister(
     IUserStore <TUser> userStore,
     UserManager <TUser> userManager)
 {
     _userStore   = userStore;
     _emailStore  = (IUserEmailStore <TUser>)_userStore;
     _userManager = userManager;
 }
Example #5
0
 public Handler(
     IUserStore <User> userStore,
     UserManager <User> userManager,
     IMailer mailer)
 {
     _userStore   = userStore;
     _emailStore  = (IUserEmailStore <User>)_userStore;
     _userManager = userManager;
     _mailer      = mailer;
 }
Example #6
0
        private IUserEmailStore <TUser> GetEmailStore(bool throwOnFail = true)
        {
            IUserEmailStore <TUser> store = Store as IUserEmailStore <TUser>;

            if (throwOnFail && store == null)
            {
                throw new NotSupportedException("Store isn't an email store!");
            }

            return(store);
        }
Example #7
0
        public virtual async Task <bool> IsEmailConfirmedAsync(TUser user)
        {
            ThrowIfDisposed();
            IUserEmailStore <TUser> emailStore = GetEmailStore();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            return(await emailStore.GetEmailConfirmedAsync(user, CancellationToken));
        }
Example #8
0
 public HomeController(
     UserManager <IdentityUser> userManager,
     IUserStore <IdentityUser> userStore,
     ILogger <HomeController> logger,
     IServiceProvider serviceProvider)
 {
     _signInManager = ActivatorUtilities.CreateInstance <MySignInManager <IdentityUser> >(serviceProvider);
     _userManager   = userManager;
     _userStore     = userStore;
     _emailStore    = GetEmailStore();
     _logger        = logger;
 }
 public ExternalLoginModel(
     SignInManager <TUser> signInManager,
     UserManager <TUser> userManager,
     IUserStore <TUser> userStore,
     ILogger <ExternalLoginModel <TUser> > logger)
 {
     _signInManager = signInManager;
     _userManager   = userManager;
     _userStore     = userStore;
     _emailStore    = GetEmailStore();
     _logger        = logger;
 }
Example #10
0
 public ExternalLoginModel(
     UserManager <IdentityUser> userManager,
     IUserStore <IdentityUser> userStore,
     ILogger <ExternalLoginModel> logger,
     IServiceProvider serviceProvider)
 {
     _signInManager = ActivatorUtilities.CreateInstance <MySignInManager <IdentityUser> >(serviceProvider);
     _userManager   = userManager;
     _userStore     = userStore;
     _emailStore    = GetEmailStore();
     _logger        = logger;
 }
 public RegisterController(IUserStore <User> userStore,
                           IUserEmailStore <User> userEmailStore,
                           UserManager <User> userManager,
                           IEmailSender emailSender,
                           SignInManager <User> signInManager)
 {
     _userStore      = userStore;
     _userEmailStore = userEmailStore;
     _userManager    = userManager;
     _emailSender    = emailSender;
     _signInManager  = signInManager;
 }
 public CreateUserModel(
     UserManager <PortalUser> userManager,
     IUserStore <PortalUser> userStore,
     ILogger <CreateUserModel> logger,
     ClientIntegratorDbContext dbContext)
 {
     _userManager   = userManager;
     _userStore     = userStore;
     _emailStore    = GetEmailStore();
     _logger        = logger;
     this.dbContext = dbContext;
 }
Example #13
0
 public Handler(
     SignInManager <User> signInManager,
     IUserStore <User> userStore,
     UserManager <User> userManager,
     IMailer mailer,
     IUserSession userSession)
 {
     _userStore   = userStore;
     _emailStore  = (IUserEmailStore <User>)_userStore;
     _userManager = userManager;
     _mailer      = mailer;
     _userSession = userSession;
 }
Example #14
0
        public AccountController(
            SignInManager <IdentityUser> signInManager,
            UserManager <IdentityUser> userManager,
            IUserStore <IdentityUser> userStore,
            IEmailSender emailSender)
        {
            _signInManager = signInManager;
            _userManager   = userManager;
            _userStore     = userStore;
            _emailSender   = emailSender;

            _emailStore = GetEmailStore();
        }
Example #15
0
 public RegisterModel(
     UserManager <Cliente> userManager,
     IUserStore <Cliente> userStore,
     SignInManager <Cliente> signInManager,
     ILogger <RegisterModel> logger,
     IEmailSender emailSender)
 {
     _userManager   = userManager;
     _userStore     = userStore;
     _emailStore    = (IUserEmailStore <Cliente>)GetEmailStore();
     _signInManager = signInManager;
     _logger        = logger;
     _emailSender   = emailSender;
 }
 public ExternalLoginModel(
     SignInManager <IdentityUser> signInManager,
     UserManager <IdentityUser> userManager,
     IUserStore <IdentityUser> userStore,
     ILogger <ExternalLoginModel> logger,
     IEmailSender emailSender)
 {
     _signInManager = signInManager;
     _userManager   = userManager;
     _userStore     = userStore;
     _emailStore    = GetEmailStore();
     _logger        = logger;
     _emailSender   = emailSender;
 }
Example #17
0
 public RegisterModel(
     UserManager <IdentityUser> userManager,
     IUserStore <IdentityUser> userStore,
     SignInManager <IdentityUser> signInManager,
     ILogger <RegisterModel> logger,
     IEmailSender emailSender)
 {
     _userManager   = userManager;
     _userStore     = userStore;
     _emailStore    = GetEmailStore();
     _signInManager = signInManager;
     _logger        = logger;
     _emailSender   = emailSender;
 }
Example #18
0
 public RegisterModel(
     UserManager <TUser> userManager,
     IUserStore <TUser> userStore,
     SignInManager <TUser> signInManager,
     ILogger <LoginModel <TUser> > logger,
     IEmailSender emailSender)
 {
     _userManager   = userManager;
     _userStore     = userStore;
     _emailStore    = GetEmailStore();
     _signInManager = signInManager;
     _logger        = logger;
     _emailSender   = emailSender;
 }
Example #19
0
        public DiTestController(
            // the Microsoft.AspNetCore.Identity User and Role Manager classes
            RoleManager <IdentityRole> roleManager,
            UserManager <ApplicationUser> userManager,

            IIdentityDatabaseContext <ApplicationUser, IdentityRole, string> identityDatabaseContext,

            // if want to use with SOLID and Interface Segregation Principle, then can just use the specific interface that need

            // these interfaces are all implemented by UserStore
            IUserStore <ApplicationUser> userStore,
            IUserLoginStore <ApplicationUser> userLoginStore,
            IUserRoleStore <ApplicationUser> userRoleStore,
            IUserClaimStore <ApplicationUser> userClaimStore,
            IUserPasswordStore <ApplicationUser> userPasswordStore,
            IUserSecurityStampStore <ApplicationUser> userSecurityStampStore,
            IUserEmailStore <ApplicationUser> userEmailStore,
            IUserLockoutStore <ApplicationUser> userLockoutStore,
            IUserPhoneNumberStore <ApplicationUser> userPhoneNumberStore,
            IUserTwoFactorStore <ApplicationUser> userTwoFactorStore,
            IQueryableUserStore <ApplicationUser> queryableUserStore,

            // these interfaces are all implemented by RoleStore
            IRoleStore <IdentityRole> roleStore,
            IRoleClaimStore <IdentityRole> roleClaimStore,
            IQueryableRoleStore <IdentityRole> queryableRoleStore
            )
        {
            _roleManager = roleManager;
            _userManager = userManager;

            _identityDatabaseContext = identityDatabaseContext;
            _userStore              = userStore;
            _userLoginStore         = userLoginStore;
            _userRoleStore          = userRoleStore;
            _userClaimStore         = userClaimStore;
            _userPasswordStore      = userPasswordStore;
            _userSecurityStampStore = userSecurityStampStore;
            _userEmailStore         = userEmailStore;
            _userLockoutStore       = userLockoutStore;
            _userPhoneNumberStore   = userPhoneNumberStore;
            _userTwoFactorStore     = userTwoFactorStore;
            _queryableUserStore     = queryableUserStore;

            _roleStore          = roleStore;
            _roleClaimStore     = roleClaimStore;
            _queryableRoleStore = queryableRoleStore;
        }
Example #20
0
 public UserDisplayDriver(
     UserManager <IUser> userManager,
     IUserService userService,
     IRoleProvider roleProvider,
     IUserStore <IUser> userStore,
     IUserEmailStore <IUser> userEmailStore,
     IUserRoleStore <IUser> userRoleStore,
     IStringLocalizer <UserDisplayDriver> stringLocalizer)
 {
     _userManager    = userManager;
     _userService    = userService;
     _roleProvider   = roleProvider;
     _userStore      = userStore;
     _userEmailStore = userEmailStore;
     _userRoleStore  = userRoleStore;
     T = stringLocalizer;
 }
Example #21
0
        public virtual async Task <AuthResult> ConfirmEmailAsync(TUser user, string token)
        {
            ThrowIfDisposed();
            IUserEmailStore <TUser> emailStore = GetEmailStore();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            //           if(false)
            //               return AuthResult.Failed(ErrorDescriber.InvalidToken());

            await emailStore.SetEmailConfirmedAsync(user, true, CancellationToken);

            return(await UpdateUserAsync(user));
        }
        public AccountController(IConfiguration configuration, MySignInManager signInManager, MyUserManager userManager,
                                 IUserStore <MyUser> userStore)
            : base(configuration)
        {
            Configuration = configuration;
            SignInManager = signInManager;
            UserManager   = userManager;
            UserStore     = userStore;

            if (UserManager.SupportsUserEmail)
            {
                EmailStore = (IUserEmailStore <MyUser>)UserStore;
            }
            else
            {
                throw new Exception("Soporte de Emails sin habilitar");
            }
        }
Example #23
0
        public virtual async Task <AuthResult> SetEmailAsync(TUser user, string email)
        {
            ThrowIfDisposed();
            IUserEmailStore <TUser> emailStore = GetEmailStore();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            await emailStore.SetEmailAsync(user, email, CancellationToken);

            await emailStore.SetEmailConfirmedAsync(user, false, CancellationToken);

            await UpdateSecurityStampInternal(user);

            return(await UpdateUserAsync(user));
        }
Example #24
0
        public async Task <ActionResult> Create(InputModel newUser)
        {
            User user = Activator.CreateInstance <User>();

            await userStore.SetUserNameAsync(user, newUser.Username, CancellationToken.None);

            IUserEmailStore <User> emailStore = userStore as IUserEmailStore <User>;
            await emailStore.SetEmailAsync(user, newUser.Email, CancellationToken.None);

            AuthResult result = await userManager.CreateAsync(user, newUser.Password);

            if (result.Succeeded)
            {
                logger.LogInformation(LoggerEventIds.UserCreated, "New user created!");
                return(RedirectToAction("Index", "User"));
            }

            ViewData["Error"] = result.ToString();
            return(View());
        }
Example #25
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            ReturnUrl = returnUrl;
            if (ModelState.IsValid)
            {
                User user = Activator.CreateInstance <User>();

                await UserStore.SetUserNameAsync(user, Input.Username, CancellationToken.None);

                IUserEmailStore <User> emailStore = UserStore as IUserEmailStore <User>;
                await emailStore.SetEmailAsync(user, Input.Email, CancellationToken.None);

                AuthResult result = await UserManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    Logger.LogInformation(LoggerEventIds.UserCreated, "New user created!");

                    if (UserManager.Options.SignIn.RequireConfirmedAccount)
                    {
                        // DEV ONLY
                        await emailStore.SetEmailConfirmedAsync(user, true, CancellationToken.None);

                        await SignInManager.SignInAsync(user, false);

                        if (returnUrl == null)
                        {
                            return(LocalRedirect("~/"));
                        }
                        else
                        {
                            return(LocalRedirect(returnUrl));
                        }
                    }
                }
            }
            return(Page());
        }
 public LoginService(UserManager <MongoIdentityUser> userManager, SignInManager <MongoIdentityUser> signInManager, IUserEmailStore <MongoIdentityUser> mongoUserStore)
 {
     this.userManager    = userManager;
     this.signInManager  = signInManager;
     this.mongoUserStore = mongoUserStore;
 }
 public AccountController(IUserStore <PhiUser> userStore, IUserProfileStore userProfileStore, IUserEmailStore <PhiUser> emailStore)
 {
     UserManager            = new PhiUserManager(userStore);
     this._userProfileStore = userProfileStore;
     this._emailStore       = emailStore;
 }
Example #28
0
        public static async Task Seed(ClientIntegratorDbContext dbContext,
                                      IUserEmailStore <PortalUser> emailStore,
                                      IUserStore <PortalUser> userStore, UserManager <PortalUser> userManager,
                                      RoleManager <PortalRole> roleManager, IConfiguration configuration)
        {
            //seed organization
            var organization = await dbContext.Organizations.FirstOrDefaultAsync();

            if (organization == null)
            {
                organization = new Organization
                {
                    DisplayName       = "Test Org",
                    CreateAt          = DateTime.UtcNow,
                    CreateBy          = 1,
                    ClientId          = "test clientId",
                    ClientSecret      = "test clientSecret",
                    ShowUsersAllFiles = true
                };

                dbContext.Organizations.Add(organization);
                dbContext.Organizations.Add(new Organization
                {
                    DisplayName       = "second Test Org",
                    CreateAt          = DateTime.UtcNow,
                    CreateBy          = 1,
                    ClientId          = "second test clientId",
                    ClientSecret      = "second test clientSecret",
                    ShowUsersAllFiles = true
                });

                dbContext.Organizations.Add(new Organization
                {
                    DisplayName       = "another Test Org",
                    CreateAt          = DateTime.UtcNow,
                    CreateBy          = 1,
                    ClientId          = "another test clientId",
                    ClientSecret      = "another test clientSecret",
                    ShowUsersAllFiles = true
                });
                await dbContext.SaveChangesAsync();
            }

            //seed configurations
            var record = await dbContext.Configurations.FirstOrDefaultAsync();

            if (record == null)
            {
                await dbContext.AddAsync(new DataAccess.Models.Configuration()
                {
                    Value             = "4",
                    Notes             = "Allowed thread count for multi-threading",
                    OrganizationId    = organization.Id,
                    ConfigurationDict = new ConfigurationDict()
                    {
                        Notes        = "Default allowed thread count for multi-threading",
                        DefaultValue = "4",
                        Key          = "ThreadCount",
                        CreateAt     = DateTime.UtcNow,
                        CreateBy     = 1,
                        IsActive     = true,
                        IsEncrypted  = false
                    },
                    CreateBy = 1,
                    CreateAt = DateTime.UtcNow
                });

                await dbContext.AddAsync(new DataAccess.Models.Configuration()
                {
                    Value             = "*****@*****.**",
                    Notes             = "Notification email receiver",
                    OrganizationId    = organization.Id,
                    ConfigurationDict = new ConfigurationDict()
                    {
                        Notes        = "Default notification email receiver",
                        DefaultValue = "*****@*****.**",
                        Key          = "NotificationEmail",
                        CreateAt     = DateTime.UtcNow,
                        CreateBy     = 1,
                        IsActive     = true,
                        IsEncrypted  = false
                    },
                    CreateBy = 1,
                    CreateAt = DateTime.UtcNow
                });

                await dbContext.SaveChangesAsync();
            }

            //seed roles
            bool userRoleExists = await roleManager.RoleExistsAsync("User");

            if (!userRoleExists)
            {
                await roleManager.CreateAsync(new PortalRole("User"));
            }

            bool superUserRoleExists = await roleManager.RoleExistsAsync("SuperUser");

            if (!superUserRoleExists)
            {
                await roleManager.CreateAsync(new PortalRole("SuperUser"));
            }

            bool adminRoleExists = await roleManager.RoleExistsAsync("Admin");

            if (!adminRoleExists)
            {
                await roleManager.CreateAsync(new PortalRole("Admin"));
            }

            var superUserEmails = new[] {
                "*****@*****.**",
                "*****@*****.**",
                "*****@*****.**"
            };

            var adminEmails = new[] {
                "*****@*****.**",
                "*****@*****.**",
                "*****@*****.**"
            };


            var userEmails = new[] {
                "*****@*****.**",
            };

            var password = configuration.GetValue <string>("Password");


            foreach (var email in superUserEmails)
            {
                var exists = await dbContext.Users.AnyAsync(x => x.UserName == email, CancellationToken.None);

                if (!exists)
                {
                    var user = new PortalUser();
                    user.IsActive = true;
                    user.Email    = email;
                    user.UserName = email;

                    var result = await userManager.CreateAsync(user, password);

                    if (result.Succeeded)
                    {
                        var userId = await userManager.GetUserIdAsync(user);

                        await userManager.AddToRoleAsync(user, "SuperUser");

                        var code = await userManager.GenerateEmailConfirmationTokenAsync(user);

                        await userManager.ConfirmEmailAsync(user, code);
                    }
                }
            }

            foreach (var email in adminEmails)
            {
                var exists = await dbContext.Users.AnyAsync(x => x.UserName == email, CancellationToken.None);

                if (!exists)
                {
                    var user = new PortalUser();
                    user.IsActive       = true;
                    user.OrganizationId = organization.Id;
                    user.Email          = email;
                    user.UserName       = email;

                    var result = await userManager.CreateAsync(user, password);

                    if (result.Succeeded)
                    {
                        var userId = await userManager.GetUserIdAsync(user);

                        await userManager.AddToRoleAsync(user, "Admin");

                        await userManager.AddClaimAsync(user, new Claim("OrganizationId",
                                                                        user.OrganizationId.ToString()));

                        var code = await userManager.GenerateEmailConfirmationTokenAsync(user);

                        await userManager.ConfirmEmailAsync(user, code);
                    }
                }
            }

            foreach (var email in userEmails)
            {
                var exists = await dbContext.Users.AnyAsync(x => x.UserName == email, CancellationToken.None);

                if (!exists)
                {
                    var user = new PortalUser();
                    user.IsActive       = true;
                    user.OrganizationId = organization.Id;
                    user.Email          = email;
                    user.UserName       = email;

                    var result = await userManager.CreateAsync(user, password);

                    if (result.Succeeded)
                    {
                        var userId = await userManager.GetUserIdAsync(user);

                        await userManager.AddToRoleAsync(user, "User");

                        await userManager.AddClaimAsync(user, new Claim("OrganizationId",
                                                                        user.OrganizationId.ToString()));

                        var code = await userManager.GenerateEmailConfirmationTokenAsync(user);

                        await userManager.ConfirmEmailAsync(user, code);
                    }
                }
            }
        }
Example #29
0
        public static async Task SeedProduction(ClientIntegratorDbContext dbContext, IUserEmailStore <PortalUser> emailStore, IUserStore <PortalUser> userStore, UserManager <PortalUser> userManager, RoleManager <PortalRole> roleManager, IConfiguration configuration)
        {
            var password = configuration.GetValue <string>("Password");
            //seed roles
            bool userRoleExists = await roleManager.RoleExistsAsync("User");

            if (!userRoleExists)
            {
                await roleManager.CreateAsync(new PortalRole("User"));
            }

            bool adminRoleExists = await roleManager.RoleExistsAsync("Admin");

            if (!adminRoleExists)
            {
                await roleManager.CreateAsync(new PortalRole("Admin"));
            }

            var superUserEmails = new[] {
                "*****@*****.**",
                "*****@*****.**"
            };

            foreach (var email in superUserEmails)
            {
                var exists = await dbContext.Users.AnyAsync(x => x.UserName == email, CancellationToken.None);

                if (!exists)
                {
                    var user = new PortalUser();
                    user.IsActive = true;
                    user.Email    = email;
                    user.UserName = email;

                    var result = await userManager.CreateAsync(user, password);

                    if (result.Succeeded)
                    {
                        var userId = await userManager.GetUserIdAsync(user);

                        await userManager.AddToRoleAsync(user, "SuperUser");

                        var code = await userManager.GenerateEmailConfirmationTokenAsync(user);

                        await userManager.ConfirmEmailAsync(user, code);
                    }
                }
            }

            var adminEmails = new[] {
                "*****@*****.**",
            };

            foreach (var email in adminEmails)
            {
                var exists = await dbContext.Users.AnyAsync(x => x.UserName == email, CancellationToken.None);

                if (!exists)
                {
                    var user = new PortalUser();
                    user.IsActive = true;
                    user.Email    = email;
                    user.UserName = email;

                    var result = await userManager.CreateAsync(user, password);

                    if (result.Succeeded)
                    {
                        var userId = await userManager.GetUserIdAsync(user);

                        await userManager.AddToRoleAsync(user, "Admin");

                        await userManager.AddClaimAsync(user, new Claim("OrganizationId",
                                                                        user.OrganizationId.ToString()));

                        var code = await userManager.GenerateEmailConfirmationTokenAsync(user);

                        await userManager.ConfirmEmailAsync(user, code);
                    }
                }
            }
        }
Example #30
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });


            using (var scope = app.ApplicationServices.CreateScope())
            {
                //initialize & seed database
                using (var dbContext = scope.ServiceProvider.GetService <ClientIntegratorDbContext>())
                {
                    ClientIntegratorDbContext = dbContext;
                    var connectionString = Configuration.GetConnectionString("ClientIntegratorDb");
                    if (connectionString != "InMemory")
                    {
                        //initialize & migrate to latest version
                        dbContext.Database.Migrate();
                    }

                    var roleManager = scope.ServiceProvider.GetService <RoleManager <PortalRole> >();
                    var userManager = scope.ServiceProvider.GetService <UserManager <PortalUser> >();
                    var userStore   = scope.ServiceProvider.GetService <IUserStore <PortalUser> >();

                    if (!userManager.SupportsUserEmail)
                    {
                        throw new NotSupportedException("The UI requires a user store with email support.");
                    }

                    IUserEmailStore <PortalUser> emailStore = (IUserEmailStore <PortalUser>)userStore;

                    if (!env.IsProduction())
                    {
                        DbSeeder.Seed(dbContext, emailStore, userStore, userManager, roleManager, Configuration).Wait();
                    }
                    else
                    {
                        DbSeeder.SeedProduction(dbContext, emailStore, userStore, userManager, roleManager, Configuration).Wait();
                    }
                }
            }
        }