Added minimal handling of expired tokens
parent
12f7eab798
commit
2985c58dd6
|
|
@ -5,6 +5,14 @@ export const pb = new PocketBase(import.meta.env.VITE_POCKETBASE_URL);
|
|||
|
||||
export const currentUser = ref();
|
||||
|
||||
if (pb.authStore.isValid) {
|
||||
try {
|
||||
await pb.collection("users").authRefresh();
|
||||
} catch (err) {
|
||||
pb.authStore.clear();
|
||||
}
|
||||
}
|
||||
|
||||
pb.authStore.onChange(() => {
|
||||
currentUser.value = pb.authStore.model;
|
||||
}, true);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ export const usePreferencesStore = defineStore("preferences", {
|
|||
|
||||
async init() {
|
||||
pb.authStore.onChange(async () => {
|
||||
await this.reset();
|
||||
if (pb.authStore.isValid) {
|
||||
await this.reset();
|
||||
}
|
||||
}, true);
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue