feat: add profile data

This commit is contained in:
Bart van der Braak 2024-02-01 18:10:42 +01:00
parent 482ffd7b85
commit 5158767019
39 changed files with 42 additions and 66 deletions

View file

@ -1,29 +1,8 @@
import type { LayoutServerLoad } from './$types';
// export function load({locals}){
// console.log('base token',locals.userPb.authStore.token);
// console.log('valid',locals.userPb.authStore.isValid);
// if(!locals.userPb.authStore.token) throw redirect(303,'/login');
// const user = {
// firstname: locals.userPb.authStore.baseModel.firstname
// }
// return{
// user
// }
// }
export const load: LayoutServerLoad = async ({ locals }: { locals: App.Locals }) => {
if (!locals.pocketBase.authStore.token) {
return {
authenticated: locals.pocketBase.authStore.isValid,
user: locals.pocketBase.authStore.model?.baseModel
};
} else {
return {
authenticated: locals.pocketBase.authStore.isValid,
user: {}
};
}
return {
authenticated: locals.pocketBase.authStore.isValid,
user: locals.pocketBase.authStore.model,
};
};

View file

@ -22,6 +22,7 @@
</main>
<SiteFooter />
{#if dev}
<!-- <pre>{JSON.stringify(data, null, 2)}</pre> -->
<TailwindIndicator />
{/if}
</div>