remove cookie auth from backend, add initial types to frontend
This commit is contained in:
parent
c6eaf49779
commit
aeb044d1a0
12 changed files with 101 additions and 21 deletions
|
@ -1,12 +1,13 @@
|
|||
import request from "$lib/request";
|
||||
import request, { getToken } from "$lib/request";
|
||||
import type { User, Meta } from "$lib/entities";
|
||||
|
||||
export async function load({ fetch, cookies }) {
|
||||
const meta = await request("GET", "/meta", { fetchFn: fetch });
|
||||
const meta = await request<Meta>("GET", "/meta", { fetchFn: fetch });
|
||||
|
||||
let user;
|
||||
if (cookies.get("pronounscc-token")) {
|
||||
user = await request("GET", "/users/@me", { fetchFn: fetch });
|
||||
user = await request<User>("GET", "/users/@me", { fetchFn: fetch, token: getToken(cookies) });
|
||||
}
|
||||
|
||||
return { meta, user };
|
||||
return { meta, user, token: getToken(cookies) };
|
||||
}
|
||||
|
|
|
@ -8,4 +8,8 @@
|
|||
|
||||
{JSON.stringify(data.meta)}
|
||||
|
||||
{#if data.user}
|
||||
{JSON.stringify(data.user)}
|
||||
{/if}
|
||||
|
||||
<slot />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue