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

Fixed ability for user to edit any property of themselves, including rights, flags. Note to self: schemas.json is a GENERATED file. npm run generate:schema in api/

This commit is contained in:
Madeline 2022-04-23 01:07:59 +10:00
parent ed69bbbe47
commit 5c27b52334
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
3 changed files with 12479 additions and 8151 deletions

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,6 @@ const Excluded = [
];
function modify(obj) {
delete obj.additionalProperties;
for (var k in obj) {
if (typeof obj[k] === "object" && obj[k] !== null) {
modify(obj[k]);

View File

@ -34,6 +34,7 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res:
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"] });
user.assign(body);
if (body.password) {
if (user.data?.hash) {
@ -46,8 +47,6 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res:
}
}
user.assign(body);
if (body.new_password) {
if (!body.password && !user.email) {
throw FieldErrors({