authenticationRevoked method

Future<bool> authenticationRevoked(
  1. String userIdentifier,
  2. SerializableModel message
)

Broadcasts revoked authentication events to the Serverpod framework. This message ensures authenticated connections to the user are closed.

The userIdentifier should be the AuthenticationInfo.userIdentifier for the concerned user.

The message must be of type RevokedAuthenticationUser, RevokedAuthenticationAuthId, or RevokedAuthenticationScope.

RevokedAuthenticationUser is used to communicate that all the user's authentication is revoked.

RevokedAuthenticationAuthId is used to communicate that a specific authentication id has been revoked for a user.

RevokedAuthenticationScope is used to communicate that a specific scope or scopes have been revoked for the user.

Implementation

Future<bool> authenticationRevoked(
  String userIdentifier,
  SerializableModel message,
) async {
  if (message is! RevokedAuthenticationUser &&
      message is! RevokedAuthenticationAuthId &&
      message is! RevokedAuthenticationScope) {
    throw ArgumentError(
      'Message must be of type RevokedAuthenticationUser, '
      'RevokedAuthenticationAuthId, or RevokedAuthenticationScope',
    );
  }

  return _session.server.messageCentral.postMessage(
    MessageCentralServerpodChannels.revokedAuthentication(userIdentifier),
    message,
  );
}