Skip to content

Commit 885379e

Browse files
committed
refactor(jwt_auth_token_service): optimize logging in validateToken and invalidateToken methods
- Replace multiple _log method calls with chained calls using .. operator - Consolidate log statements in JwtAuthTokenService class - Improve code readability and reduce line count for better maintainability
1 parent 0d666c4 commit 885379e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/src/services/jwt_auth_token_service.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ class JwtAuthTokenService implements AuthTokenService {
165165
// Fetch the full user object from the repository
166166
// This ensures the user still exists and is valid
167167
final user = await _userRepository.read(id: userId);
168-
_log.finer('[validateToken] User repository read successful for ID: $userId');
169-
_log.info('[validateToken] Token validated successfully for user ${user.id}');
168+
_log..finer('[validateToken] User repository read successful for ID: $userId')
169+
..info('[validateToken] Token validated successfully for user ${user.id}');
170170
return user;
171171
} on JWTExpiredException catch (e, s) {
172172
_log.warning('[validateToken] Token expired.', e, s);
@@ -243,10 +243,10 @@ class JwtAuthTokenService implements AuthTokenService {
243243
expClaim * 1000,
244244
isUtc: true,
245245
);
246-
_log.finer('[invalidateToken] Extracted expiry: $expiryDateTime');
246+
_log..finer('[invalidateToken] Extracted expiry: $expiryDateTime')
247247

248248
// 4. Add JTI to the blacklist
249-
_log.finer('[invalidateToken] Adding jti $jti to blacklist...');
249+
..finer('[invalidateToken] Adding jti $jti to blacklist...');
250250
await _blacklistService.blacklist(jti, expiryDateTime);
251251
_log.info('[invalidateToken] Token (jti: $jti) successfully blacklisted.');
252252
} on JWTException catch (e, s) {

0 commit comments

Comments
 (0)