tyep fixes
This commit is contained in:
parent
15df6f4401
commit
a5dc9b32be
6 changed files with 38 additions and 12 deletions
16
src/app.d.ts
vendored
Normal file
16
src/app.d.ts
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
declare global {
|
||||
namespace App {
|
||||
interface Error {
|
||||
status: number;
|
||||
message: string;
|
||||
}
|
||||
interface Locals {
|
||||
user: User;
|
||||
}
|
||||
interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
|
@ -15,18 +15,17 @@ const PUBLIC_RESOURCES = [
|
|||
export async function handle({ event, resolve }) {
|
||||
const { cookies, locals } = event;
|
||||
const session = await getSession(cookies.get(COOKIE));
|
||||
const user = session?.user;
|
||||
|
||||
if (user) {
|
||||
if (session && session.user) {
|
||||
locals.user = {
|
||||
id: user?.id,
|
||||
username: user?.username,
|
||||
email: user?.email
|
||||
id: session.user.id,
|
||||
username: session.user.username,
|
||||
email: session.user.email
|
||||
};
|
||||
}
|
||||
|
||||
} else {
|
||||
if (event.route.id) {
|
||||
if (event.route.id.includes('(app)') && !user) return redirect(303, '/');
|
||||
if (event.route.id.includes('(app)')) return redirect(303, '/');
|
||||
}
|
||||
}
|
||||
|
||||
return await resolve(event);
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
export const COOKIE = '.FILE-UPLOADER-SESSION';
|
||||
|
||||
export const MAIL_WHITELIST = ['gmail.com', 'outlook.com', 'madhouselabs.net', 'dfuser.xyz'];
|
||||
export const MAIL_WHITELIST = [
|
||||
'gmail.com',
|
||||
'outlook.com',
|
||||
'madhouselabs.net',
|
||||
'dfuser.xyz',
|
||||
'liloandstit.ch'
|
||||
];
|
||||
|
|
5
src/lib/types/user.d.ts
vendored
Normal file
5
src/lib/types/user.d.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
interface User {
|
||||
id: number;
|
||||
username: string;
|
||||
email: string;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { user } from '$lib/stores';
|
||||
import ThemeSwitcher from '$lib/components/ThemeSwitcher.svelte';
|
||||
|
||||
import Button from '$lib/components/Inputs/Button.svelte';
|
||||
import ButtonText from '$lib/components/Inputs/ButtonText.svelte';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/** @type {import('@sveltejs/kit').Load} */
|
||||
/** @type {import('@sveltejs/kit').ServerLoad} */
|
||||
export const load = async ({ locals }) => {
|
||||
return {
|
||||
user: locals.user
|
||||
|
|
Loading…
Reference in a new issue