示例#1
0
 public async Task AddUserAsync(MockUser user, string password)
 {
     var userExsits = await UserExists(user);
     if (userExsits)
     {
         throw new Exception(
             "A user with that Email address already exists");
     }
     var hasher = new MockPasswordHasher();
     user.PasswordHash = hasher.CreateHash(password).ToString();
     _dbContext.Users.Add(user);
     await _dbContext.SaveChangesAsync();
 }
示例#2
0
 public bool PasswordIsValid(MockUser user, string password)
 {
     var hasher = new MockPasswordHasher();
     var hash = hasher.CreateHash(password);
     return hash.Equals(user.PasswordHash);
 }