refactor: login in /auth, temporary logout

This commit is contained in:
EETagent 2022-12-03 15:18:03 +01:00
parent 62c901d9c9
commit cc224f0091
5 changed files with 16 additions and 3 deletions

View file

@ -1,7 +1,7 @@
import { goto } from "$app/navigation";
import type { AxiosError } from "axios";
export const API_URL = "http://localhost:8000";
export const API_URL = "http://localhost:9000";
export interface ApiError {
error: AxiosError,

View file

@ -5,6 +5,6 @@ import { redirect } from '@sveltejs/kit';
export const load: LayoutServerLoad = ({ cookies }) => {
const isAuthenticated = cookies.get('id');
if (!isAuthenticated) {
throw redirect(302, '/login');
throw redirect(302, '/auth/login');
}
};

View file

@ -10,7 +10,7 @@
const redirectToCode = () => {
// TODO: Validation
if (applicationValue) {
goto(`/login/${applicationValue}`);
goto(`login/${applicationValue}`);
}
};
</script>

View file

@ -0,0 +1,13 @@
import type { PageServerLoad } from './$types';
import { redirect } from '@sveltejs/kit';
import { logout } from '$lib/stores/candidate';
export const load: PageServerLoad = async ({ cookies }) => {
// TODO: Nefunguje?!
await logout();
console.log(cookies);
cookies.delete('id', {path: '/'});
cookies.delete('key', {path: '/'});
throw redirect(302, '/auth/login');
};