fix: make sure $settingsPub is not undefined #242

This commit is contained in:
seriousm4x
2023-10-01 13:31:03 +02:00
parent 7d2b3a7a4c
commit 7168ca283f
2 changed files with 7 additions and 7 deletions

View File

@@ -57,7 +57,7 @@
}
// redirect to welcome page if setup is not completed
if (!$settingsPub.setup_completed && $page.url.pathname !== '/welcome') {
if ($settingsPub.setup_completed === false && $page.url.pathname !== '/welcome') {
goto('/welcome');
return;
}
@@ -81,17 +81,17 @@
return;
}
if ($pocketbase.authStore.model?.collectionName === 'users') {
if ($pocketbase.authStore.isAdmin) {
await $pocketbase.admins.authRefresh().catch(() => {
goto('/login');
});
} else {
await $pocketbase
.collection('users')
.authRefresh()
.catch(() => {
goto('/login');
});
} else {
await $pocketbase.admins.authRefresh().catch(() => {
goto('/login');
});
}
});

View File

@@ -19,7 +19,7 @@
};
onMount(() => {
if (!$settingsPub.setup_completed && $pocketbase.authStore.isValid) {
if ($settingsPub && $settingsPub.setup_completed === false && $pocketbase.authStore.isValid) {
$pocketbase.authStore.clear();
}
});