Ejemplo n.º 1
0
 public async Task AddUserAsync(CustomUser user, string password)
 {
     if (await UserExists(user))
     {
         throw new Exception(
             "A user with that Email address already exists");
     }
     var hasher = new CustomPasswordHasher();
     user.PasswordHash = hasher.CreateHash(password).ToString();
     _db.Users.Add(user);
     await _db.SaveChangesAsync();
 }
Ejemplo n.º 2
0
 public bool PasswordIsValid(CustomUser user, string password)
 {
     var hasher = new CustomPasswordHasher();
     var hash = hasher.CreateHash(password);
     return hash.Equals(user.PasswordHash);
 }