Skip to content

Commit b4c66de

Browse files
committed
chore: authentication handler
1 parent 77f68d6 commit b4c66de

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

apps/api/src/main.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,13 @@ server.get("/", async function (request, response) {
8686
// JWT authentication hook
8787
server.addHook("preHandler", async function (request: any, reply: any) {
8888
try {
89+
if (request.url === "/api/v1/auth/login" && request.method === "POST") {
90+
return true;
91+
}
8992
const bearer = request.headers.authorization!.split(" ")[1];
90-
return checkToken(bearer);
93+
checkToken(bearer);
9194
} catch (err) {
92-
reply.send({
95+
reply.status(401).send({
9396
message: "Unauthorized",
9497
success: false,
9598
});

apps/client/pages/auth/login.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ export default function Login({}) {
5252
.then((res) => {
5353
if (res.success && res.url) {
5454
setUrl(res.url);
55-
} else {
56-
if (!res.success) {
57-
toast({
58-
variant: "destructive",
59-
title: "Error",
60-
description:
61-
"There was an error logging in, please try again. If this issue persists, please contact support via the discord.",
62-
});
63-
}
6455
}
6556
});
6657
}

0 commit comments

Comments
 (0)