From 3f1b833c823715fe1c5c66585ce17956f55f0db9 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Sat, 29 Jul 2023 16:23:14 +0200 Subject: [PATCH] fix login --- src/routes/(admin-panel)/login/+page.server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/(admin-panel)/login/+page.server.ts b/src/routes/(admin-panel)/login/+page.server.ts index ddad0d6..4ef2eb2 100644 --- a/src/routes/(admin-panel)/login/+page.server.ts +++ b/src/routes/(admin-panel)/login/+page.server.ts @@ -1,4 +1,4 @@ -import { redirect } from '@sveltejs/kit'; +import { HttpError, redirect } from '@sveltejs/kit'; import type { Actions, PageServerLoad } from './$types'; import { APIError } from '$lib/api/request'; import { getLoggedInUser, login, logout } from '$lib/api/auth'; @@ -28,7 +28,6 @@ export const actions = { try { await login(cookies, username, password); - throw redirect(302, url.searchParams.get('then') || '/admin'); } catch (e) { if (e instanceof APIError) { switch (e.code) { @@ -38,6 +37,7 @@ export const actions = { } return { error: 'unknown internal error' }; } + throw redirect(302, url.searchParams.get('then') || '/admin'); }, logout: async ({ url, cookies }) => { await logout(cookies);