Emails class

Collection of utility methods when working with email authentication.

Constructors

Emails()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

authenticate(Session session, String email, String password) Future<AuthenticationResponse>
Authenticates a user with email and password. Returns an AuthenticationResponse with the users information.
changePassword(Session session, int userId, String oldPassword, String newPassword) Future<bool>
Updates the password of a user.
createAccountRequest(Session session, String userName, String email, String password) Future<bool>
Creates a request for creating an account associated with the specified email address. An email with a validation code will be sent.
createUser(Session session, String userName, String email, String? password, [String? hash]) Future<UserInfo?>
Creates a new user. Either password or hash needs to be provided.
findAccountRequest(Session session, String email) Future<EmailCreateAccountRequest?>
Returns an EmailCreateAccountRequest if one exists for the provided email, null otherwise.
generatePasswordHash(String password) Future<String>
Generates a password hash from a users password and email. This value can safely be stored in the database without the risk of exposing passwords.
initiatePasswordReset(Session session, String email) Future<bool>
Initiates the password reset procedure. Will send an email to the provided address with a reset code.
migrateLegacyPasswordHashes(Session session, {int batchSize = 100, int? maxMigratedEntries}) Future<int>
Migrates legacy password hashes to the latest hash algorithm.
resetPassword(Session session, String verificationCode, String password) Future<bool>
Resets a users password using a password reset verification code.
tryMigrateAuthEntry({required String password, required EmailAuth entry}) Future<EmailAuth?>
Migrates an EmailAuth entry if required.
validatePasswordHash(String password, String email, String hash, {void onValidationFailure({required String passwordHash, required String storedHash})?, void onError(Object e)?}) Future<bool>
Generates a password hash from the password using the provided hash algorithm and validates that they match.
verifyEmailPasswordReset(Session session, String verificationCode) Future<EmailPasswordReset?>
Verifies a password reset code, returns a EmailPasswordReset object if successful, null otherwise.