@@ -192,37 +192,42 @@ class AuthService {
192
192
/// The primary client-side action (clearing the local token) is handled
193
193
/// separately by the client application.
194
194
///
195
- /// Throws: This implementation currently does not throw exceptions under
196
- /// normal circumstances. Future implementations involving token
197
- /// invalidation might throw [OperationFailedException] if invalidation fails.
198
- Future <void > performSignOut ({required String userId}) async {
199
- // Log the attempt.
195
+ /// Performs server-side sign-out actions, including token invalidation.
196
+ ///
197
+ /// Invalidates the provided authentication [token] using the
198
+ /// [AuthTokenService] .
199
+ ///
200
+ /// The primary client-side action (clearing the local token) is handled
201
+ /// separately by the client application.
202
+ ///
203
+ /// Throws [OperationFailedException] if token invalidation fails.
204
+ Future <void > performSignOut ({
205
+ required String userId,
206
+ required String token,
207
+ }) async {
200
208
print (
201
209
'[AuthService] Received request for server-side sign-out actions '
202
210
'for user $userId .' ,
203
211
);
204
212
205
- // --- Placeholder for Future Token Invalidation ---
206
- // If AuthTokenService had an invalidateToken method, it would be called here:
207
- // try {
208
- // // Assuming the token itself or its JTI was passed or derivable
209
- // // String tokenToInvalidate = ...;
210
- // // await _authTokenService.invalidateToken(tokenToInvalidate);
211
- // print('[AuthService] Token invalidation logic executed (if implemented).');
212
- // } catch (e) {
213
- // print('[AuthService] Error during token invalidation for user $userId: $e');
214
- // // Decide whether to rethrow or just log
215
- // // throw OperationFailedException('Failed server-side sign-out: $e');
216
- // }
217
- // ------------------------------------------------
218
-
219
- // Simulate potential async work if needed in the future.
220
- await Future <void >.delayed (Duration .zero);
213
+ try {
214
+ // Invalidate the token using the AuthTokenService
215
+ await _authTokenService.invalidateToken (token);
216
+ print ('[AuthService] Token invalidation logic executed for user $userId .' );
217
+ } on HtHttpException catch (_) {
218
+ // Propagate known exceptions from the token service
219
+ rethrow ;
220
+ } catch (e) {
221
+ // Catch unexpected errors during token invalidation
222
+ print ('[AuthService] Error during token invalidation for user $userId : $e ' );
223
+ throw OperationFailedException (
224
+ 'Failed server-side sign-out: Token invalidation failed.' ,
225
+ );
226
+ }
221
227
222
228
print (
223
229
'[AuthService] Server-side sign-out actions complete for user $userId .' ,
224
230
);
225
- // No specific exceptions are thrown in this placeholder implementation.
226
231
}
227
232
228
233
/// Initiates the process of linking an [emailToLink] to an existing
0 commit comments