From 9f5c451cbc8bfb714479312c0cdc7349a836505f Mon Sep 17 00:00:00 2001 From: Featyre Date: Wed, 2 Feb 2022 02:09:57 +0800 Subject: Return none for dev portal + todo for categories --- api/src/routes/users/@me/guilds.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'api/src/routes/users/@me') diff --git a/api/src/routes/users/@me/guilds.ts b/api/src/routes/users/@me/guilds.ts index 22a2c04c..754a240e 100644 --- a/api/src/routes/users/@me/guilds.ts +++ b/api/src/routes/users/@me/guilds.ts @@ -8,7 +8,13 @@ const router: Router = Router(); router.get("/", route({}), async (req: Request, res: Response) => { const members = await Member.find({ relations: ["guild"], where: { id: req.user_id } }); - res.json(members.map((x) => x.guild)); + let guild = members.map((x) => x.guild); + + if ("with_counts" in req.query && req.query.with_counts == "true") { + guild = []; // TODO: Load guilds with user role permissions number + } + + res.json(guild); }); // user send to leave a certain guild -- cgit 1.5.1 From 4eae64b91a296d49e8bb1bc833f2531301eb459a Mon Sep 17 00:00:00 2001 From: RealMANI <96433859+ImAaronFR@users.noreply.github.com> Date: Wed, 16 Feb 2022 11:15:37 +0330 Subject: [Fix] Invisible space username (#639) You can send only spaces to the server and have a invisible username, this way you can remove the spaces and check and if it wasn't null after you know it's not just spaces --- api/src/routes/users/@me/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'api/src/routes/users/@me') diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts index 1959704a..acca8910 100644 --- a/api/src/routes/users/@me/index.ts +++ b/api/src/routes/users/@me/index.ts @@ -57,6 +57,13 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res: user.data.hash = await bcrypt.hash(body.new_password, 12); } + var check_username = body?.username?.replace(/\s/g, ''); + if(!check_username) { + throw FieldErrors({ + username: { code: "BASE_TYPE_REQUIRED", message: req.t("common:field.BASE_TYPE_REQUIRED") } + }); + } + await user.save(); // @ts-ignore -- cgit 1.5.1