1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 12:42:44 +01:00

Prevent demo user from editing their profile

This commit is contained in:
Madeline 2022-07-03 00:02:01 +10:00
parent c18fe9c0b3
commit 6b8c4c9fa7
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47

View File

@ -2,6 +2,7 @@ import { Router, Request, Response } from "express";
import { User, PrivateUserProjection, emitEvent, UserUpdateEvent, handleFile, FieldErrors, adjustEmail } from "@fosscord/util";
import { route } from "@fosscord/api";
import bcrypt from "bcrypt";
import { HTTPError } from "lambert-server";
const router: Router = Router();
@ -29,6 +30,8 @@ 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;
if (body.avatar) body.avatar = await handleFile(`/avatars/${req.user_id}`, body.avatar as string);