From b4c66dea1eb25663560e08750489096febb91e2b Mon Sep 17 00:00:00 2001 From: Jack Andrews Date: Wed, 13 Nov 2024 19:20:02 +0000 Subject: [PATCH] chore: authentication handler --- apps/api/src/main.ts | 7 +++++-- apps/client/pages/auth/login.tsx | 9 --------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 4a3cafd60..ff059c8ff 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -86,10 +86,13 @@ server.get("/", async function (request, response) { // JWT authentication hook server.addHook("preHandler", async function (request: any, reply: any) { try { + if (request.url === "/api/v1/auth/login" && request.method === "POST") { + return true; + } const bearer = request.headers.authorization!.split(" ")[1]; - return checkToken(bearer); + checkToken(bearer); } catch (err) { - reply.send({ + reply.status(401).send({ message: "Unauthorized", success: false, }); diff --git a/apps/client/pages/auth/login.tsx b/apps/client/pages/auth/login.tsx index 79603f7ee..34be0e7dc 100644 --- a/apps/client/pages/auth/login.tsx +++ b/apps/client/pages/auth/login.tsx @@ -52,15 +52,6 @@ export default function Login({}) { .then((res) => { if (res.success && res.url) { setUrl(res.url); - } else { - if (!res.success) { - toast({ - variant: "destructive", - title: "Error", - description: - "There was an error logging in, please try again. If this issue persists, please contact support via the discord.", - }); - } } }); }