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);