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();
|
export const currentUser = ref();
|
||||||
|
|
||||||
|
if (pb.authStore.isValid) {
|
||||||
|
try {
|
||||||
|
await pb.collection("users").authRefresh();
|
||||||
|
} catch (err) {
|
||||||
|
pb.authStore.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pb.authStore.onChange(() => {
|
pb.authStore.onChange(() => {
|
||||||
currentUser.value = pb.authStore.model;
|
currentUser.value = pb.authStore.model;
|
||||||
}, true);
|
}, true);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,9 @@ export const usePreferencesStore = defineStore("preferences", {
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
pb.authStore.onChange(async () => {
|
pb.authStore.onChange(async () => {
|
||||||
|
if (pb.authStore.isValid) {
|
||||||
await this.reset();
|
await this.reset();
|
||||||
|
}
|
||||||
}, true);
|
}, true);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue