mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 19:36:41 +02:00
email and username checks on profile update
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
"email-not-confirmed": "Your email is not confirmed, please click here to confirm your email.",
|
||||
|
||||
"username-too-short": "Username too short",
|
||||
"username-too-long": "Username too long",
|
||||
|
||||
"user-banned": "User banned",
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@ module.exports = function(User) {
|
||||
return next();
|
||||
}
|
||||
|
||||
if (!utils.isEmailValid(data.email)) {
|
||||
return next(new Error('[[error:invalid-email]]'));
|
||||
}
|
||||
|
||||
User.getUserField(uid, 'email', function(err, email) {
|
||||
if(email === data.email) {
|
||||
return next();
|
||||
@@ -53,6 +57,14 @@ module.exports = function(User) {
|
||||
return next();
|
||||
}
|
||||
|
||||
if (data.username.length < meta.config.minimumUsernameLength) {
|
||||
return next(new Error('[[error:username-too-short]]'));
|
||||
}
|
||||
|
||||
if (data.username.length > meta.config.maximumUsernameLength) {
|
||||
return next(new Error('[[error:username-too-long]]'));
|
||||
}
|
||||
|
||||
if(!utils.isUserNameValid(data.username) || !userslug) {
|
||||
return next(new Error('[[error:invalid-username]]'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user