mirror of
https://github.com/spacebarchat/server.git
synced 2026-11-29 20:58:07 +00:00
🐛 fix token checking
This commit is contained in:
1 parent
54b6a8ea31
commit
eca7b96de3
3 files changed
+10
-4
No files matched your search
@@ -18,8 +18,13 @@ export async function Authentication(req: Request, res: Response, next: NextFunc
|
||||
if (!req.headers.authorization) return next(new HTTPError("Missing Authorization Header", 401));
|
||||
// TODO: check if user is banned/token expired
|
||||
|
||||
const decoded: any = await checkToken(req.headers.authorization);
|
||||
try {
|
||||
const decoded: any = await checkToken(req.headers.authorization);
|
||||
|
||||
req.token = decoded;
|
||||
req.userid = decoded.id;
|
||||
req.token = decoded;
|
||||
req.userid = decoded.id;
|
||||
return next();
|
||||
} catch (error) {
|
||||
return next(error);
|
||||
}
|
||||
}
|
||||
@@ -169,10 +169,11 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) =
|
||||
data: guild,
|
||||
guild_id: guildID,
|
||||
} as GuildCreateEvent);
|
||||
|
||||
res.status(201).json({ id: guild.id });
|
||||
} catch (error) {
|
||||
throw new HTTPError("Couldnt create Guild", 500);
|
||||
}
|
||||
res.status(201).json({ id: guild.id });
|
||||
});
|
||||
|
||||
router.delete("/:id", async (req: Request, res: Response) => {
|
||||
|
||||
Reference in new issue
Block a user