logout functionality hopefully
This commit is contained in:
parent
16651fce27
commit
a967a298cb
7 changed files with 62 additions and 14 deletions
|
@ -168,7 +168,6 @@ export function initAuth(router: express.Router) {
|
|||
export function apiTokenAuthHandlers() {
|
||||
return [
|
||||
passport.authenticate("api-token", { failWithError: true, session: false }),
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
(err, req: Request, res: Response, next) => {
|
||||
return res.status(401).json({ error: err.message });
|
||||
},
|
||||
|
|
19
pnpm-lock.yaml
generated
19
pnpm-lock.yaml
generated
|
@ -438,6 +438,9 @@ importers:
|
|||
autoprefixer:
|
||||
specifier: ^10.4.20
|
||||
version: 10.4.20(postcss@8.4.47)
|
||||
axios:
|
||||
specifier: ^1.7.7
|
||||
version: 1.7.7
|
||||
eslint:
|
||||
specifier: ^9.7.0
|
||||
version: 9.14.0(jiti@1.21.6)
|
||||
|
@ -2451,6 +2454,9 @@ packages:
|
|||
aws4@1.13.2:
|
||||
resolution: {integrity: sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==}
|
||||
|
||||
axios@1.7.7:
|
||||
resolution: {integrity: sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==}
|
||||
|
||||
axobject-query@4.1.0:
|
||||
resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
@ -6610,6 +6616,9 @@ packages:
|
|||
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}
|
||||
engines: {node: '>= 0.10'}
|
||||
|
||||
proxy-from-env@1.1.0:
|
||||
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
|
||||
|
||||
ps-tree@1.2.0:
|
||||
resolution: {integrity: sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA==}
|
||||
engines: {node: '>= 0.10'}
|
||||
|
@ -10803,6 +10812,14 @@ snapshots:
|
|||
|
||||
aws4@1.13.2: {}
|
||||
|
||||
axios@1.7.7:
|
||||
dependencies:
|
||||
follow-redirects: 1.15.9
|
||||
form-data: 4.0.1
|
||||
proxy-from-env: 1.1.0
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
|
||||
axobject-query@4.1.0: {}
|
||||
|
||||
b4a@1.6.7: {}
|
||||
|
@ -15283,6 +15300,8 @@ snapshots:
|
|||
forwarded: 0.2.0
|
||||
ipaddr.js: 1.9.1
|
||||
|
||||
proxy-from-env@1.1.0: {}
|
||||
|
||||
ps-tree@1.2.0:
|
||||
dependencies:
|
||||
event-stream: 3.3.4
|
||||
|
|
|
@ -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
Reference in a new issue