signOutUser static method

Future<void> signOutUser(
  1. Session session, {
  2. int? userId,
})

Signs out a user from the server and deletes all authentication keys. This means that the user will be signed out from all connected devices.

Implementation

static Future<void> signOutUser(Session session, {int? userId}) async {
  userId ??= (await session.authenticated)?.userId;
  if (userId == null) return;

  await session.db
      .deleteWhere<AuthKey>(where: AuthKey.t.userId.equals(userId));
  await session.messages
      .authenticationRevoked(userId, RevokedAuthenticationUser());
  session.updateAuthenticated(null);
}