delete static method

Future<void> delete(
  1. Session session, {
  2. required UuidValue authUserId,
  3. Transaction? transaction,
})

Removes the specified auth user.

This also removes all authentication-related entities from all serverpod_auth_* packages which are linked to this user, like the various authentication methods and sessions. (This is based on the onDelete=Cascade relationship between the models. Other packages linking to the AuthUser may or may not opt into this.)

Throws an AuthUserNotFoundException in case no auth user is found for the ID.

Implementation

static Future<void> delete(
  final Session session, {
  required final UuidValue authUserId,
  final Transaction? transaction,
}) async {
  final deletedUsers = await AuthUser.db.deleteWhere(
    session,
    where: (final t) => t.id.equals(authUserId),
    transaction: transaction,
  );

  if (deletedUsers.isEmpty) {
    throw AuthUserNotFoundException();
  }
}