This commit is contained in:
Barış Soner Uşaklı
2026-01-19 22:26:09 -05:00
parent 84bd409a7c
commit 7e27da61ab
2 changed files with 16 additions and 18 deletions

View File

@@ -84,17 +84,7 @@ authenticationController.register = async function (req, res) {
await user.verifyInvitation(userData);
}
if (
!userData.username ||
userData.username.length < meta.config.minimumUsernameLength ||
slugify(userData.username).length < meta.config.minimumUsernameLength
) {
throw new Error('[[error:username-too-short]]');
}
if (userData.username.length > meta.config.maximumUsernameLength) {
throw new Error('[[error:username-too-long]]');
}
user.checkUsernameLength(userData.username);
if (userData.password !== userData['password-confirm']) {
throw new Error('[[user:change-password-error-match]]');

View File

@@ -170,13 +170,7 @@ module.exports = function (User) {
}
}
if (data.username.length < meta.config.minimumUsernameLength) {
throw new Error('[[error:username-too-short]]');
}
if (data.username.length > meta.config.maximumUsernameLength) {
throw new Error('[[error:username-too-long]]');
}
User.checkUsernameLength(data.username);
const userslug = slugify(data.username);
if (!utils.isUserNameValid(data.username) || !userslug) {
@@ -201,6 +195,20 @@ module.exports = function (User) {
}
User.checkUsername = async username => isUsernameAvailable({ username });
User.checkUsernameLength = function (username) {
if (
!username ||
username.length < meta.config.minimumUsernameLength ||
slugify(username).length < meta.config.minimumUsernameLength
) {
throw new Error('[[error:username-too-short]]');
}
if (username.length > meta.config.maximumUsernameLength) {
throw new Error('[[error:username-too-long]]');
}
};
async function isAboutMeValid(callerUid, data) {
if (!data.aboutme) {
return;