public async Task <User> Register(User user, string password) { byte[] passwordHash, passwordSalt; _helper.CreatePasswordHash(password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; await _dataContext.Users.AddAsync(user); await _dataContext.SaveChangesAsync(); return(user); }
public void SeedUsers() { var userData = File.ReadAllText("Data/UserSeedData.json"); var users = JsonConvert.DeserializeObject <List <User> >(userData); foreach (var user in users) { byte[] passwordHash, passwordSalt; _helper.CreatePasswordHash("password", out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; user.Username = user.Username.ToLower(); _dataContext.Users.Add(user); } _dataContext.SaveChanges(); }