Consistent username length requirement

This commit is contained in:
TomatoCake 2024-08-17 15:39:55 +02:00
parent bb31df036a
commit 8e28f2539c
3 changed files with 17 additions and 9 deletions

View File

@ -287,6 +287,16 @@ router.post(
}); });
} }
const { maxUsername } = Config.get().limits.user;
if (body.username.length > maxUsername) {
throw FieldErrors({
username: {
code: "USERNAME_INVALID",
message: `Username must be less than ${maxUsername} in length`,
},
});
}
const user = await User.register({ ...body, req }); const user = await User.register({ ...body, req });
if (body.invite) { if (body.invite) {

View File

@ -19,7 +19,6 @@
export interface RegisterSchema { export interface RegisterSchema {
/** /**
* @minLength 2 * @minLength 2
* @maxLength 32
*/ */
username: string; username: string;
/** /**

View File

@ -18,8 +18,7 @@
export interface UserModifySchema { export interface UserModifySchema {
/** /**
* @minLength 1 * @minLength 2
* @maxLength 100
*/ */
username?: string; username?: string;
avatar?: string | null; avatar?: string | null;