14 lines
442 B
TypeScript
14 lines
442 B
TypeScript
import { auth } from '$lib/core/stores/auth.js';
|
|
import { departmentStore } from '$lib/core/stores/departments.ts';
|
|
import { redirect } from '@sveltejs/kit';
|
|
import { get } from 'svelte/store';
|
|
|
|
export async function load({ cookies, url }) {
|
|
if (!cookies.get('logged_in')) {
|
|
redirect(303, `/login?redirectTo=${url.pathname}`);
|
|
}
|
|
|
|
if (url.pathname.includes('recipe') && !cookies.get('department')) {
|
|
redirect(303, `/departments`);
|
|
}
|
|
}
|