summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.DS_Storebin8196 -> 8196 bytes
-rw-r--r--src/middlewares/Authentication.ts11
-rw-r--r--src/routes/api/v8/guilds/index.ts3
3 files changed, 10 insertions, 4 deletions
diff --git a/.DS_Store b/.DS_Store

index 7baa692a..0510bdb2 100644 --- a/.DS_Store +++ b/.DS_Store
Binary files differdiff --git a/src/middlewares/Authentication.ts b/src/middlewares/Authentication.ts
index d6eb5796..2bb8a124 100644 --- a/src/middlewares/Authentication.ts +++ b/src/middlewares/Authentication.ts
@@ -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); + } } diff --git a/src/routes/api/v8/guilds/index.ts b/src/routes/api/v8/guilds/index.ts
index 93d5292e..f2c9d556 100644 --- a/src/routes/api/v8/guilds/index.ts +++ b/src/routes/api/v8/guilds/index.ts
@@ -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) => {