Example #1
0
        public static void SeedUsers(ZaiZaiDateDbContext dbContext)
        {
            if (dbContext is null)
            {
                throw new ArgumentNullException(nameof(dbContext));
            }

            if (dbContext.Users.Any())
            {
                return;
            }

            var userData = ReadUsersFile();
            var users    = JsonConvert.DeserializeObject <List <AppUser> >(userData);

            foreach (var user in users)
            {
                byte[] passwordHash, passwordSalt;
                CreatePasswordHash("pwd12345", out passwordHash, out passwordSalt);

                user.PasswordHash = passwordHash;
                user.PasswordSalt = passwordSalt;
                user.UserName     = user.UserName.ToLowerInvariant();
                user.CreatedDate  = DateTimeOffset.UtcNow;
                dbContext.Users.Add(user);
            }
            dbContext.SaveChanges();
        }
Example #2
0
 public AuthenticationService(ZaiZaiDateDbContext dbContext)
 {
     _dbContext = dbContext;
 }
 public UserManagementService(ZaiZaiDateDbContext dbContext)
 {
     _dbContext = dbContext;
 }