refactor: remove ActionGuard and MenuProtection components, simplifying permission checks in various dashboard routes and enhancing footer with privacy policy link
This commit is contained in:
@@ -3,16 +3,16 @@ import { api } from '@sgse-app/backend/convex/_generated/api';
|
||||
import { error, redirect } from '@sveltejs/kit';
|
||||
import type { FunctionReference } from 'convex/server';
|
||||
|
||||
export const load = async ({ locals }) => {
|
||||
export const load = async ({ locals, url }) => {
|
||||
if (!locals.token) {
|
||||
throw redirect(302, '/login');
|
||||
throw redirect(302, '/login?redirect=' + url.pathname);
|
||||
}
|
||||
try {
|
||||
const client = createConvexHttpClient({ token: locals.token });
|
||||
const currentUser = await client.query(api.auth.getCurrentUser as FunctionReference<'query'>);
|
||||
|
||||
if (!currentUser) {
|
||||
throw redirect(302, '/login');
|
||||
throw redirect(302, '/login?redirect=' + url.pathname);
|
||||
}
|
||||
return { currentUser };
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user