startRegistration static method

Future<void> startRegistration(
  1. Session session, {
  2. required String email,
  3. required String password,
  4. Transaction? transaction,
})

Starts the registration for a new user account with an email-based login associated to it.

Upon successful completion of this method, an email will have been sent to email with a verification link, which the user must open to complete the registration.

Implementation

static Future<void> startRegistration(
  final Session session, {
  required final String email,
  required final String password,
  final Transaction? transaction,
}) async {
  final result = await EmailAccounts.startAccountCreation(
    session,
    email: email,
    password: password,
    transaction: transaction,
  );

  // The details of the operation are intentionally not given to the caller, in order to not leak the existence of accounts.
  // Clients should always show something like "check your email to proceed with the account creation".
  // One might want to send a "password reset" in case of a "email already exists" status, to help the user log in.
  if (result.result != EmailAccountRequestResult.accountRequestCreated) {
    session.log(
      'Failed to start account registration for $email, reason: ${result.result}',
      level: LogLevel.debug,
    );
  }
}