public User PasswordUpdate(User user) { if (string.IsNullOrEmpty(user.Email) || string.IsNullOrEmpty(user.Password)) { return(null); } user = _userRepository.Get(new User { Email = user.Email }); if (user == null) { throw new Exception("User not found"); } byte[] passwordHash, passwordSalt; PasswordExtension.CreatePasswordHash(user.Password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; _userRepository.Update(user); return(user); }
public User Create(User user) { try { var UserData = _userRepository.Get(new User { Email = user.Email }); if (UserData != null) { throw new Exception("O email informado não está disponível."); } byte[] passwordHash, passwordSalt; PasswordExtension.CreatePasswordHash(user.Password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; _userRepository.Insert(user); return(user); } catch (Exception) { throw; } }