mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-25 11:43:07 +01:00
Merge pull request from GHSA-hqqp-gpqw-9w5c
This commit is contained in:
parent
51239d60f6
commit
69c55884e5
@ -8424,7 +8424,9 @@
|
||||
},
|
||||
"members": {
|
||||
"type": "array",
|
||||
"items": {}
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"thread_member_lists": {
|
||||
"type": "array",
|
||||
@ -21846,6 +21848,8 @@
|
||||
"type": "string"
|
||||
},
|
||||
"discriminator": {
|
||||
"minLength": 4,
|
||||
"maxLength": 4,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
@ -23047,9 +23051,6 @@
|
||||
"UserSettingsSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"index": {
|
||||
"type": "string"
|
||||
},
|
||||
"afk_timeout": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -44,9 +44,9 @@ router.patch(
|
||||
|
||||
user.settings.assign(body);
|
||||
|
||||
user.settings.save();
|
||||
await user.settings.save();
|
||||
|
||||
res.json(user.settings);
|
||||
res.json({ ...user.settings, index: undefined });
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -246,27 +246,20 @@ export class User extends BaseClass {
|
||||
|
||||
if (this.discriminator) {
|
||||
const discrim = Number(this.discriminator);
|
||||
if (this.discriminator.length > 4)
|
||||
throw FieldErrors({
|
||||
discriminator: {
|
||||
message: "Discriminator cannot be more than 4 digits.",
|
||||
code: "DISCRIMINATOR_INVALID",
|
||||
},
|
||||
});
|
||||
if (isNaN(discrim))
|
||||
throw FieldErrors({
|
||||
discriminator: {
|
||||
message: "Discriminator must be a number.",
|
||||
code: "DISCRIMINATOR_INVALID",
|
||||
},
|
||||
});
|
||||
if (discrim <= 0 || discrim >= 10000)
|
||||
if (
|
||||
isNaN(discrim) ||
|
||||
!(typeof discrim == "number") ||
|
||||
!Number.isInteger(discrim) ||
|
||||
discrim <= 0 ||
|
||||
discrim >= 10000
|
||||
)
|
||||
throw FieldErrors({
|
||||
discriminator: {
|
||||
message: "Discriminator must be a number.",
|
||||
code: "DISCRIMINATOR_INVALID",
|
||||
},
|
||||
});
|
||||
|
||||
this.discriminator = discrim.toString().padStart(4, "0");
|
||||
}
|
||||
}
|
||||
|
@ -33,5 +33,9 @@ export interface UserModifySchema {
|
||||
new_password?: string;
|
||||
code?: string;
|
||||
email?: string;
|
||||
/**
|
||||
* @minLength 4
|
||||
* @maxLength 4
|
||||
*/
|
||||
discriminator?: string;
|
||||
}
|
||||
|
@ -18,4 +18,4 @@
|
||||
|
||||
import { UserSettings } from "@fosscord/util";
|
||||
|
||||
export type UserSettingsSchema = Partial<UserSettings>;
|
||||
export type UserSettingsSchema = Omit<Partial<UserSettings>, "index">;
|
||||
|
Loading…
Reference in New Issue
Block a user