Node.js based forum software built for the modern web
allow changing username if user has no password set, ie sso login
barisusakli28ae101d90d7
diff --git a/src/socket.io/user/profile.js b/src/socket.io/user/profile.jsindex 396fb0b265..1661eac92c 100644--- a/src/socket.io/user/profile.js+++ b/src/socket.io/user/profile.js@@ -25,12 +25,9 @@ module.exports = function(SocketUser) {function isAdminOrSelfAndPasswordMatch(uid, data, callback) {async.parallel({- isAdmin: function(next) {- user.isAdministrator(uid, next);- },- passwordMatch: function(next) {- user.isPasswordCorrect(data.uid, data.password, next);- }+ isAdmin: async.apply(user.isAdministrator, uid),+ hasPassword: async.apply(user.hasPassword, data.uid),+ passwordMatch: async.apply(user.isPasswordCorrect, data.uid, data.password)}, function(err, results) {if (err) {return callback(err);@@ -41,7 +38,7 @@ module.exports = function(SocketUser) {return callback(new Error('[[error:no-privileges]]'));}- if (self && !results.passwordMatch) {+ if (self && results.hasPassword && !results.passwordMatch) {return callback(new Error('[[error:invalid-password]]'));}diff --git a/src/user/password.js b/src/user/password.jsindex 0c15cd07e7..b326313be4 100644--- a/src/user/password.js+++ b/src/user/password.js@@ -25,4 +25,10 @@ module.exports = function(User) {});};+ User.hasPassword = function(uid, callback) {+ db.getObjectField('user:' + uid, 'password', function(err, hashedPassword) {+ callback(err, !!hashedPassword);+ });+ };+};\ No newline at end of file