Skip to content

Commit

Permalink
fix: make sure $settingsPub is not undefined #242
Browse files Browse the repository at this point in the history
  • Loading branch information
seriousm4x committed Oct 1, 2023
1 parent 7d2b3a7 commit 7168ca2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions frontend/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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');
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routes/welcome/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
};
onMount(() => {
if (!$settingsPub.setup_completed && $pocketbase.authStore.isValid) {
if ($settingsPub && $settingsPub.setup_completed === false && $pocketbase.authStore.isValid) {
$pocketbase.authStore.clear();
}
});
Expand Down

0 comments on commit 7168ca2

Please sign in to comment.