Skip to content

Commit

Permalink
chore: authentication handler
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Nov 13, 2024
1 parent 77f68d6 commit b4c66de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
7 changes: 5 additions & 2 deletions apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
9 changes: 0 additions & 9 deletions apps/client/pages/auth/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
});
}
}
});
}
Expand Down

0 comments on commit b4c66de

Please sign in to comment.