public void CreateAdminUser(AdminSetupModel adminSetupModel) { if (_connectionString == null) { _connectionString = ConfigurationManager.ConnectionStrings["eFormMainConnection"].ConnectionString; } // Seed admin and demo users var manager = new EformUserManager(new EformUserStore(new BaseDbContext(_connectionString))); var adminUser = new EformUser() { UserName = adminSetupModel.UserName, Email = adminSetupModel.Email, FirstName = adminSetupModel.FirstName, LastName = adminSetupModel.LastName, EmailConfirmed = true, TwoFactorEnabled = false, IsGoogleAuthenticatorEnabled = false }; if (!manager.Users.Any(x => x.Email.Equals(adminUser.Email))) { IdentityResult ir = manager.Create(adminUser, adminSetupModel.Password); if (ir != null) { manager.AddToRole(adminUser.Id, "admin"); } else { throw new Exception("Could not create the user"); } } }
protected override void Dispose(bool disposing) { if (disposing && _userManager != null) { _userManager.Dispose(); _userManager = null; } base.Dispose(disposing); }
public void CreateAdminUser(AdminSetupModel adminSetupModel) { if (_connectionString == null) { _connectionString = ConfigurationManager.ConnectionStrings["eFormMainConnection"].ConnectionString; } // Seed admin and demo users var manager = new EformUserManager(new EformUserStore(new BaseDbContext(_connectionString))); var adminUser = new EformUser() { UserName = adminSetupModel.UserName, Email = adminSetupModel.Email, FirstName = adminSetupModel.FirstName, LastName = adminSetupModel.LastName, EmailConfirmed = true, }; if (!manager.Users.Any(x => x.Email.Equals(adminUser.Email))) { manager.Create(adminUser, adminSetupModel.Password); manager.AddToRole(adminUser.Id, "admin"); } }
public AccountController(EformUserManager userManager, ISecureDataFormat <AuthenticationTicket> accessTokenFormat) { UserManager = userManager; AccessTokenFormat = accessTokenFormat; }