revokeToken static method
Future<void>
revokeToken(
- Client cloudApiClient, {
- required CommandLogger logger,
- required String tokenId,
- required String localStoragePath,
Implementation
static Future<void> revokeToken(
final Client cloudApiClient, {
required final CommandLogger logger,
required final String tokenId,
required final String localStoragePath,
}) async {
final bool currentSessionRevoked;
try {
currentSessionRevoked = await cloudApiClient.authWithAuth.logoutDevice(
authTokenId: tokenId,
);
} on NotFoundException catch (e) {
throw FailureException(error: e.message);
} on Exception catch (e, s) {
throw FailureException.nested(e, s, 'Failed to revoke token');
}
if (!currentSessionRevoked) {
logger.success('Successfully logged out the selected sessions.');
return;
}
try {
await ResourceManager.removeServerpodCloudAuthData(
localStoragePath: localStoragePath,
);
} on Exception catch (e, s) {
throw FailureException.nested(
e,
s,
'Failed to remove stored credentials',
'Please remove these manually. '
'They should be located in $localStoragePath.',
);
}
logger.success('Successfully logged out from Serverpod cloud.');
}