From 22e369804b2a6ed82a6da2c469519cd7252693a0 Mon Sep 17 00:00:00 2001 From: Thuan Pham Quoc Date: Fri, 1 Dec 2017 15:55:53 +0700 Subject: Allow admin to change user password in admin panel --- client/components/settings/peopleBody.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'client/components/settings/peopleBody.js') diff --git a/client/components/settings/peopleBody.js b/client/components/settings/peopleBody.js index d0da60d0..7cc992f2 100644 --- a/client/components/settings/peopleBody.js +++ b/client/components/settings/peopleBody.js @@ -87,24 +87,26 @@ Template.editUserPopup.events({ const user = Users.findOne(this.userId); const fullname = tpl.find('.js-profile-fullname').value.trim(); const username = tpl.find('.js-profile-username').value.trim(); - const initials = tpl.find('.js-profile-initials').value.trim(); + const password = tpl.find('.js-profile-password').value; const isAdmin = tpl.find('.js-profile-isadmin').value.trim(); const isActive = tpl.find('.js-profile-isactive').value.trim(); const email = tpl.find('.js-profile-email').value.trim(); - let isChangeUserName = false; - let isChangeEmail = false; + + const isChangePassword = password.length > 0; + const isChangeUserName = username !== user.username; + const isChangeEmail = email.toLowerCase() !== user.emails[0].address.toLowerCase(); Users.update(this.userId, { $set: { 'profile.fullname': fullname, - 'profile.initials': initials, 'isAdmin': isAdmin === 'true', 'loginDisabled': isActive === 'true', }, }); - isChangeUserName = username !== user.username; - isChangeEmail = email.toLowerCase() !== user.emails[0].address.toLowerCase(); + if(isChangePassword){ + Meteor.call('setPassword', password, this.userId); + } if (isChangeUserName && isChangeEmail) { Meteor.call('setUsernameAndEmail', username, email.toLowerCase(), this.userId, function (error) { -- cgit v1.2.3-1-g7c22