예제 #1
0
        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);
        }
예제 #2
0
파일: Seed.cs 프로젝트: dvladh/DatingApp
        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();
        }