Skip to content

Node.js based forum software built for the modern web

dont crash if data.username is undefined, dont set username to empty value

barisusakli7efc0619cc1a
diff --git a/src/user/profile.js b/src/user/profile.js
index 13f29591c0..8c44b86a6f 100644
--- a/src/user/profile.js
+++ b/src/user/profile.js
@@ -57,6 +57,9 @@ module.exports = function(User) {
}
function isUsernameAvailable(next) {
+ if (!data.username) {
+ return next();
+ }
User.getUserFields(uid, ['username', 'userslug'], function(err, userData) {
var userslug = utils.slugify(data.username);
@@ -177,6 +180,9 @@ module.exports = function(User) {
}
function updateUsername(uid, newUsername, callback) {
+ if (!newUsername) {
+ return callback();
+ }
User.getUserFields(uid, ['username', 'userslug'], function(err, userData) {
function update(field, object, value, callback) {
async.parallel([