mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Allow admin to change user password in admin panel
This commit is contained in:
parent
54036fd7a3
commit
22e369804b
3 changed files with 19 additions and 9 deletions
|
|
@ -67,9 +67,6 @@ template(name="editUserPopup")
|
||||||
span.error.hide.username-taken
|
span.error.hide.username-taken
|
||||||
| {{_ 'error-username-taken'}}
|
| {{_ 'error-username-taken'}}
|
||||||
input.js-profile-username(type="text" value=user.username)
|
input.js-profile-username(type="text" value=user.username)
|
||||||
label
|
|
||||||
| {{_ 'initials'}}
|
|
||||||
input.js-profile-initials(type="text" value=user.profile.initials)
|
|
||||||
label
|
label
|
||||||
| {{_ 'email'}}
|
| {{_ 'email'}}
|
||||||
span.error.hide.email-taken
|
span.error.hide.email-taken
|
||||||
|
|
@ -85,5 +82,9 @@ template(name="editUserPopup")
|
||||||
select.select-active.js-profile-isactive
|
select.select-active.js-profile-isactive
|
||||||
option(value="false") {{_ 'yes'}}
|
option(value="false") {{_ 'yes'}}
|
||||||
option(value="true" selected="{{user.loginDisabled}}") {{_ 'no'}}
|
option(value="true" selected="{{user.loginDisabled}}") {{_ 'no'}}
|
||||||
|
hr
|
||||||
|
label
|
||||||
|
| {{_ 'password'}}
|
||||||
|
input.js-profile-password(type="password")
|
||||||
|
|
||||||
input.primary.wide(type="submit" value="{{_ 'save'}}")
|
input.primary.wide(type="submit" value="{{_ 'save'}}")
|
||||||
|
|
|
||||||
|
|
@ -87,24 +87,26 @@ Template.editUserPopup.events({
|
||||||
const user = Users.findOne(this.userId);
|
const user = Users.findOne(this.userId);
|
||||||
const fullname = tpl.find('.js-profile-fullname').value.trim();
|
const fullname = tpl.find('.js-profile-fullname').value.trim();
|
||||||
const username = tpl.find('.js-profile-username').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 isAdmin = tpl.find('.js-profile-isadmin').value.trim();
|
||||||
const isActive = tpl.find('.js-profile-isactive').value.trim();
|
const isActive = tpl.find('.js-profile-isactive').value.trim();
|
||||||
const email = tpl.find('.js-profile-email').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, {
|
Users.update(this.userId, {
|
||||||
$set: {
|
$set: {
|
||||||
'profile.fullname': fullname,
|
'profile.fullname': fullname,
|
||||||
'profile.initials': initials,
|
|
||||||
'isAdmin': isAdmin === 'true',
|
'isAdmin': isAdmin === 'true',
|
||||||
'loginDisabled': isActive === 'true',
|
'loginDisabled': isActive === 'true',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
isChangeUserName = username !== user.username;
|
if(isChangePassword){
|
||||||
isChangeEmail = email.toLowerCase() !== user.emails[0].address.toLowerCase();
|
Meteor.call('setPassword', password, this.userId);
|
||||||
|
}
|
||||||
|
|
||||||
if (isChangeUserName && isChangeEmail) {
|
if (isChangeUserName && isChangeEmail) {
|
||||||
Meteor.call('setUsernameAndEmail', username, email.toLowerCase(), this.userId, function (error) {
|
Meteor.call('setUsernameAndEmail', username, email.toLowerCase(), this.userId, function (error) {
|
||||||
|
|
|
||||||
|
|
@ -372,6 +372,13 @@ Meteor.methods({
|
||||||
Meteor.call('setUsername', username, userId);
|
Meteor.call('setUsername', username, userId);
|
||||||
Meteor.call('setEmail', email, userId);
|
Meteor.call('setEmail', email, userId);
|
||||||
},
|
},
|
||||||
|
setPassword(newPassword, userId) {
|
||||||
|
check(userId, String);
|
||||||
|
check(newPassword, String);
|
||||||
|
if(Meteor.user().isAdmin){
|
||||||
|
Accounts.setPassword(userId, newPassword);
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue