From 7a0ca3f82a637bcfe4cf43af4c2cff37060fb6ce Mon Sep 17 00:00:00 2001 From: Scriptbash <98601298+Scriptbash@users.noreply.github.com> Date: Sat, 11 Apr 2026 13:25:18 -0400 Subject: [PATCH] refresh auth on app start --- lib/services/pocketbase_service.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 {