summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-02-05 12:35:27 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-02-05 12:35:27 +1100
commitcc50ebf47b0cb4b19b68436037eff20d96874b3e (patch)
treea965b327906537454141a45ce6132a7d9d81d261 /src/api
parentDon't use relative path for db entities. Closes #937 (diff)
downloadserver-cc50ebf47b0cb4b19b68436037eff20d96874b3e.tar.xz
Fix being unable to unset nicknames
Remove unwanted guild profile handler in cdn
Fix rights check for bio/avatars of your own user
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/guilds/#guild_id/members/#member_id/index.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/api/routes/guilds/#guild_id/members/#member_id/index.ts b/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
index d40f2772..6ac0dd3b 100644
--- a/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
+++ b/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
@@ -65,9 +65,19 @@ router.patch(
 
 		if ("nick" in body) {
 			permission.hasThrow("MANAGE_NICKNAMES");
+
+			if (!body.nick) {
+				delete body.nick;
+				// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+				//@ts-ignore shut up
+				member.nick = null; // remove the nickname
+			}
 		}
 
-		if (("bio" in body || "avatar" in body) && member_id != "@me") {
+		if (
+			("bio" in body || "avatar" in body) &&
+			req.params.member_id != "@me"
+		) {
 			const rights = await getRights(req.user_id);
 			rights.hasThrow("MANAGE_USERS");
 		}