🐛 fix token checking

This commit is contained in:
Flam3rboy 2021-02-17 18:12:07 +01:00
parent 54b6a8ea31
commit eca7b96de3
3 changed files with 10 additions and 4 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -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)); if (!req.headers.authorization) return next(new HTTPError("Missing Authorization Header", 401));
// TODO: check if user is banned/token expired // 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.token = decoded;
req.userid = decoded.id; req.userid = decoded.id;
return next();
} catch (error) {
return next(error);
}
} }

View File

@ -169,10 +169,11 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) =
data: guild, data: guild,
guild_id: guildID, guild_id: guildID,
} as GuildCreateEvent); } as GuildCreateEvent);
res.status(201).json({ id: guild.id });
} catch (error) { } catch (error) {
throw new HTTPError("Couldnt create Guild", 500); throw new HTTPError("Couldnt create Guild", 500);
} }
res.status(201).json({ id: guild.id });
}); });
router.delete("/:id", async (req: Request, res: Response) => { router.delete("/:id", async (req: Request, res: Response) => {