mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-24 12:35:31 +00:00
refactor: login in /auth, temporary logout
This commit is contained in:
parent
62c901d9c9
commit
cc224f0091
5 changed files with 16 additions and 3 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
const redirectToCode = () => {
|
||||
// TODO: Validation
|
||||
if (applicationValue) {
|
||||
goto(`/login/${applicationValue}`);
|
||||
goto(`login/${applicationValue}`);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
13
frontend/src/routes/(candidate)/auth/logout/+page.server.ts
Normal file
13
frontend/src/routes/(candidate)/auth/logout/+page.server.ts
Normal 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');
|
||||
};
|
||||
Loading…
Reference in a new issue