findAccount method

Future<({UuidValue authUserId, UuidValue emailAccountId, bool hasPassword})?> findAccount(
  1. Session session, {
  2. required String email,
  3. Transaction? transaction,
})

Checks whether an email authentication exists for the given email address.

Implementation

Future<
    ({
      UuidValue authUserId,
      UuidValue emailAccountId,
      bool hasPassword,
    })?> findAccount(
  final Session session, {
  required String email,
  final Transaction? transaction,
}) async {
  email = email.toLowerCase();

  final account = await EmailAccount.db.findFirstRow(
    session,
    where: (final t) => t.email.equals(email),
    transaction: transaction,
  );

  if (account == null) {
    return null;
  }

  return (
    authUserId: account.authUserId,
    emailAccountId: account.id!,
    hasPassword: account.passwordHash.lengthInBytes > 0,
  );
}