diff --git a/public/src/forum/accountedit.js b/public/src/forum/accountedit.js
index 13bab6cf9d..207785e846 100644
--- a/public/src/forum/accountedit.js
+++ b/public/src/forum/accountedit.js
@@ -189,8 +189,7 @@ define(['forum/accountheader', 'uploader'], function(header, uploader) {
password_confirm.on('blur', onPasswordConfirmChanged);
$('#changePasswordBtn').on('click', function() {
-
- if (passwordvalid && passwordsmatch && (currentPassword.val() || app.isAdmin)) {
+ if ((passwordvalid && passwordsmatch) || app.isAdmin) {
socket.emit('user.changePassword', {
'currentPassword': currentPassword.val(),
'newPassword': password.val(),
diff --git a/public/templates/accountedit.tpl b/public/templates/accountedit.tpl
index acfe85af56..536943b7b5 100644
--- a/public/templates/accountedit.tpl
+++ b/public/templates/accountedit.tpl
@@ -115,7 +115,7 @@
diff --git a/src/user.js b/src/user.js
index 4674e1d17b..9d81f2ea71 100644
--- a/src/user.js
+++ b/src/user.js
@@ -185,8 +185,13 @@ var bcrypt = require('bcryptjs'),
return callback(err);
}
- if (data && data.password) {
- delete data.password;
+ if (data) {
+ if (data.password) {
+ delete data.password;
+ data.hasPassword = true;
+ } else {
+ data.hasPassword = false;
+ }
}
callback(err, data);
});
@@ -467,13 +472,18 @@ var bcrypt = require('bcryptjs'),
return callback(err);
}
- bcrypt.compare(data.currentPassword, currentPassword, function(err, res) {
- if (err || !res) {
- return callback(err || new Error('Your current password is not correct!'));
- }
+ if (currentPassword !== null) {
+ bcrypt.compare(data.currentPassword, currentPassword, function(err, res) {
+ if (err || !res) {
+ return callback(err || new Error('Your current password is not correct!'));
+ }
+ hashAndSetPassword(callback);
+ });
+ } else {
+ // No password in account (probably SSO login)
hashAndSetPassword(callback);
- });
+ }
});
}
};