logout functionality hopefully
This commit is contained in:
parent
16651fce27
commit
a967a298cb
7 changed files with 62 additions and 14 deletions
|
@ -22,6 +22,7 @@
|
|||
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
||||
"@types/eslint": "^9.6.0",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"axios": "^1.7.7",
|
||||
"eslint": "^9.7.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-svelte": "^2.36.0",
|
||||
|
|
19
revampdashboard/src/app.d.ts
vendored
19
revampdashboard/src/app.d.ts
vendored
|
@ -1,13 +1,18 @@
|
|||
// See https://svelte.dev/docs/kit/types#app.d.ts
|
||||
// for information about these interfaces
|
||||
import type { AxiosInstance } from 'axios';
|
||||
|
||||
declare global {
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
}
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
interface Locals {
|
||||
comm: AxiosInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
|
|
16
revampdashboard/src/hooks.server.ts
Normal file
16
revampdashboard/src/hooks.server.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import type { Handle } from '@sveltejs/kit';
|
||||
import axios from 'axios';
|
||||
|
||||
export const handle: Handle = async ({ event, resolve }) => {
|
||||
const apiKey = event.cookies.get('apiKey') ?? '';
|
||||
|
||||
event.locals.comm = axios.create({
|
||||
baseURL: process.env.API_URL,
|
||||
timeout: 10000,
|
||||
headers: {
|
||||
'X-Api-Key': apiKey
|
||||
}
|
||||
});
|
||||
|
||||
return resolve(event);
|
||||
};
|
13
revampdashboard/src/routes/auth/logout/+server.ts
Normal file
13
revampdashboard/src/routes/auth/logout/+server.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { redirect } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const GET: RequestHandler = async ({ locals }) => {
|
||||
try {
|
||||
await locals.comm.get('/auth/logout');
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return redirect(307, `${process.env.DASHBOARD_URL}/new`);
|
||||
}
|
||||
|
||||
return redirect(307, `${process.env.DASHBOARD_URL}/new`);
|
||||
};
|
|
@ -1,16 +1,11 @@
|
|||
<script lang="ts">
|
||||
import logo from '$lib/img/logo.png';
|
||||
import { page } from '$app/stores';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
let guildsAnchor: string = $state("/new/dashboard");
|
||||
|
||||
onMount(() => {
|
||||
console.log($page.url.pathname);
|
||||
})
|
||||
|
||||
async function logout() {
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue