Add user profiles and account setup page
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { prisma } from '$lib/db';
|
||||
import { error, redirect } from '@sveltejs/kit';
|
||||
|
||||
export const load: PageServerLoad = async ({ locals }) => {
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
id: locals.user?.id
|
||||
},
|
||||
include: {
|
||||
profile: true
|
||||
}
|
||||
});
|
||||
|
||||
if (user) {
|
||||
if (!user?.profile) {
|
||||
throw redirect(403, '/account/setup');
|
||||
}
|
||||
return { user };
|
||||
} else {
|
||||
throw error(403, 'not authorized');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type {PageProps} from "./$types";
|
||||
let {data}: PageProps = $props();
|
||||
$inspect(data);
|
||||
</script>
|
||||
Reference in New Issue
Block a user