defaultValidatePasswordHash function

Future<bool> defaultValidatePasswordHash(
  1. String password,
  2. String email,
  3. String hash, {
  4. void onValidationFailure({
    1. required String passwordHash,
    2. required String storedHash,
    })?,
  5. void onError(
    1. Object e
    )?,
})

The default validation password hash.

Warning: Using a custom hashing algorithm for passwords will permanently disrupt compatibility with Serverpod's password hash validation and migration.

Implementation

Future<bool> defaultValidatePasswordHash(
  String password,
  String email,
  String hash, {
  void Function({
    required String passwordHash,
    required String storedHash,
  })? onValidationFailure,
  void Function(Object e)? onError,
}) async {
  try {
    return await PasswordHash(
      hash,
      legacySalt: EmailSecrets.legacySalt,
      legacyEmail: AuthConfig.current.extraSaltyHash ? email : null,
      pepper: EmailSecrets.pepper,
    ).validate(password, onValidationFailure: onValidationFailure);
  } catch (e) {
    onError?.call(e);
    return false;
  }
}