Ejemplo n.º 1
0
        public static async Task SeedUsers(userdata data)
        {
            if (await data.users.AnyAsync())
            {
                return;
            }
            var seed = await System.IO.File.ReadAllTextAsync("Data/UserSeedData.json");

            var users = JsonSerializer.Deserialize <List <Appusers> >(seed);

            foreach (var user in users)
            {
                using var hmac = new HMACSHA512();

                user.PasswordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes("password"));
                user.PasswordSalt = hmac.Key;
                data.users.Add(user);
            }

            await data.SaveChangesAsync();
        }
Ejemplo n.º 2
0
 public UserRepository(userdata data, IMapper mapper)
 {
     _mapper = mapper;
     _data   = data;
 }