get user from cookie, not locals

This commit is contained in:
Alexander Bocken 2023-07-23 12:29:41 +02:00
parent 8ebc407752
commit 41f42eb2b4
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8
3 changed files with 3 additions and 16 deletions

View File

@ -2,12 +2,6 @@ import { redirect } from "@sveltejs/kit"
import type { Actions, PageServerLoad } from "./$types" import type { Actions, PageServerLoad } from "./$types"
import { error } from "@sveltejs/kit" import { error } from "@sveltejs/kit"
export const load: PageServerLoad = async ({ locals }) => {
return {
user: locals.user,
}
}
export const actions: Actions = { export const actions: Actions = {
login: async (event) => { login: async (event) => {
const data = await event.request.formData() const data = await event.request.formData()

View File

@ -1,12 +1,6 @@
import { redirect } from "@sveltejs/kit" import { redirect } from "@sveltejs/kit"
import type { Actions, PageServerLoad } from "./$types" import type { Actions, PageServerLoad } from "./$types"
export const load: PageServerLoad = async ({ locals }) => {
return {
user: locals.user,
}
}
export const actions: Actions = { export const actions: Actions = {
register: async (event) => { register: async (event) => {
const data = await event.request.formData(); const data = await event.request.formData();

View File

@ -2,10 +2,9 @@ import { redirect } from "@sveltejs/kit"
import type { Actions, PageServerLoad } from "./$types" import type { Actions, PageServerLoad } from "./$types"
import { error } from "@sveltejs/kit" import { error } from "@sveltejs/kit"
export const load: PageServerLoad = async ({ locals }) => { export const load: PageServerLoad = async ({ cookies }) => {
return { const user = await authenticateUser(cookies)
user: locals.user, return {user}
}
} }
export const actions: Actions = { export const actions: Actions = {