diff --git a/lib/services/pocketbase_service.dart b/lib/services/pocketbase_service.dart index 787529e3..408acf29 100644 --- a/lib/services/pocketbase_service.dart +++ b/lib/services/pocketbase_service.dart @@ -39,6 +39,20 @@ class PocketBaseService { _client = PocketBase(savedUrl, authStore: store); _isInitialized = true; + + await refreshAuth(); + } + + Future refreshAuth() async { + if (client.authStore.isValid) { + try { + await client.collection('users').authRefresh(); + } catch (e) { + if (e is ClientException && e.statusCode != 0) { + client.authStore.clear(); + } + } + } } Future register(String email, String password) async {