From bba8ae54d7f166ad4df7e29ec6673aece746c438 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Thu, 7 Jul 2022 23:25:46 +1000 Subject: [PATCH] Somehow the ID of demo user changed. Use email of demo instead --- api/src/routes/users/@me/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts index 7ab30f03..902a2e45 100644 --- a/api/src/routes/users/@me/index.ts +++ b/api/src/routes/users/@me/index.ts @@ -30,15 +30,15 @@ router.get("/", route({}), async (req: Request, res: Response) => { }); router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res: Response) => { - if (req.user_id === "992772978150273216") throw new HTTPError("Demo user, sorry", 400); - const body = req.body as UserModifySchema; + const user = await User.findOneOrFail({ where: { id: req.user_id }, select: [...PrivateUserProjection, "data"] }); + + if (user.email == "demo@maddy.k.vu") throw new HTTPError("Demo user, sorry", 400); + 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 User.findOneOrFail({ where: { id: req.user_id }, select: [...PrivateUserProjection, "data"] }); - if (body.password) { if (user.data?.hash) { const same_password = await bcrypt.compare(body.password, user.data.hash || "");