summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-11 19:44:26 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-11 19:44:26 +0200
commitf5c6b6166bec73fee67a99b87cffaedbf0435adf (patch)
tree3f0c4d83a4ae48f6946c38f146cc84b8bb2377a8
parent:construction: fix guild channel position (diff)
downloadserver-f5c6b6166bec73fee67a99b87cffaedbf0435adf.tar.xz
:construction: fix /users/@me patch route
-rw-r--r--src/routes/users/@me/index.ts26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/routes/users/@me/index.ts b/src/routes/users/@me/index.ts

index f6b29958..7bd4a486 100644 --- a/src/routes/users/@me/index.ts +++ b/src/routes/users/@me/index.ts
@@ -11,16 +11,38 @@ router.get("/", async (req: Request, res: Response) => { res.json(await getPublicUser(req.user_id)); }); +const UserUpdateProjection = { + accent_color: true, + avatar: true, + banner: true, + bio: true, + bot: true, + discriminator: true, + email: true, + flags: true, + id: true, + locale: true, + mfa_enabled: true, + nsfw_alllowed: true, + phone: true, + public_flags: true, + purchased_flags: true, + // token: true, // this isn't saved in the db and needs to be set manually + username: true, + verified: true +}; + router.patch("/", check(UserModifySchema), async (req: Request, res: Response) => { const body = req.body as UserModifySchema; - if(body.avatar) body.avatar = await handleFile(`/avatars/${req.user_id}`, body.avatar as string); + if (body.avatar) body.avatar = await handleFile(`/avatars/${req.user_id}`, body.avatar as string); if (body.banner) body.banner = await handleFile(`/banners/${req.user_id}`, body.banner as string); - const user = await UserModel.findOneAndUpdate({ id: req.user_id }, body, { projection: PublicUserProjection }).exec(); + const user = await UserModel.findOneAndUpdate({ id: req.user_id }, body, { projection: UserUpdateProjection }).exec(); // TODO: dispatch user update event res.json(toObject(user)); }); export default router; +// {"message": "Invalid two-factor code", "code": 60008}