fix login

This commit is contained in:
Hamcha 2023-07-29 16:23:14 +02:00
parent 4254368597
commit 3f1b833c82
Signed by: hamcha
GPG Key ID: 1669C533B8CF6D89
1 changed files with 2 additions and 2 deletions

View File

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