28 lines
805 B
Dart
28 lines
805 B
Dart
import 'package:dio/dio.dart';
|
|
|
|
import '../../auth/token_storage.dart';
|
|
import '../../marianumconnect_query.dart';
|
|
|
|
/// Revokes the stored MC bearer token both server-side and locally. Best-effort
|
|
/// — a network error still clears the local token so the user isn't stuck with
|
|
/// an unusable session.
|
|
class AuthLogout extends MarianumConnectQuery {
|
|
final MarianumConnectTokenStorage _tokenStorage;
|
|
|
|
AuthLogout({
|
|
MarianumConnectTokenStorage tokenStorage =
|
|
const MarianumConnectTokenStorage(),
|
|
super.dio,
|
|
}) : _tokenStorage = tokenStorage;
|
|
|
|
Future<void> run() async {
|
|
try {
|
|
await dio.post<void>(endpoint('auth/logout'));
|
|
} on DioException catch (_) {
|
|
// ignore — local clear below still happens
|
|
} finally {
|
|
await _tokenStorage.clear();
|
|
}
|
|
}
|
|
}
|