|
@@ -14,6 +14,7 @@ import 'package:immich_mobile/shared/services/api.service.dart';
|
|
|
import 'package:immich_mobile/utils/db.dart';
|
|
|
import 'package:immich_mobile/utils/hash.dart';
|
|
|
import 'package:isar/isar.dart';
|
|
|
+import 'package:logging/logging.dart';
|
|
|
import 'package:openapi/api.dart';
|
|
|
|
|
|
class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
|
@@ -92,21 +93,29 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Future<bool> logout() async {
|
|
|
+ Future<void> logout() async {
|
|
|
+ var log = Logger('AuthenticationNotifier');
|
|
|
try {
|
|
|
+
|
|
|
+ String? userEmail = Store.tryGet(StoreKey.currentUser)?.email;
|
|
|
+
|
|
|
+ _apiService.authenticationApi
|
|
|
+ .logout()
|
|
|
+ .then((_) => log.info("Logout was successfull for $userEmail"))
|
|
|
+ .onError(
|
|
|
+ (error, stackTrace) =>
|
|
|
+ log.severe("Error logging out $userEmail", error, stackTrace),
|
|
|
+ );
|
|
|
+
|
|
|
await Future.wait([
|
|
|
- _apiService.authenticationApi.logout(),
|
|
|
clearAssetsAndAlbums(_db),
|
|
|
Store.delete(StoreKey.currentUser),
|
|
|
Store.delete(StoreKey.accessToken),
|
|
|
]);
|
|
|
|
|
|
state = state.copyWith(isAuthenticated: false);
|
|
|
-
|
|
|
- return true;
|
|
|
} catch (e) {
|
|
|
- debugPrint("Error logging out $e");
|
|
|
- return false;
|
|
|
+ log.severe("Error logging out $e");
|
|
|
}
|
|
|
}
|
|
|
|