invalidateTokenWithStrategy method
Invalidates tokens using a specific strategy
token The access token
logoutType The type of logout strategy to use
Implementation
@override
Future<void> invalidateTokenWithStrategy(
String token,
LogoutType logoutType,
) async {
final strategy = _strategyFactory.createStrategy(logoutType);
// Verify token to get context
final jwt = JWT.verify(token, SecretKey(_secret));
final payload = jwt.payload as Map<String, dynamic>;
final exp = payload['exp'] as int?;
final userId = payload['sub'];
if (exp != null && userId != null) {
final context = TokenInvalidationContext.fromTokens(
accessToken: token,
userId: userId,
guard: _providerKey,
tokenExpiry: exp,
tokenPayload: payload,
);
await strategy.invalidateTokens(context);
}
}