Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/ui-flextab/client/tabs/userEdit.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
{{#if hasPermission 'edit-other-user-password'}}
<div class="rc-form-group rc-form-group--small rc-switch">
<label class="rc-switch__label" tabindex="-1">
<input class="rc-switch__input" type="checkbox" id="setRandomPassword" value="1" checked="{{setRandomPassword}}"/>
<input class="rc-switch__input" type="checkbox" id="setRandomPassword" value="1" checked="{{setRandomPassword}}" disabled="{{setRandomPasswordDisabled}}"/>
<span class="rc-switch__button">
<span class="rc-switch__button-inside"></span>
</span>
Expand All @@ -127,7 +127,7 @@
</div>
<div class="rc-form-group rc-form-group--small rc-switch">
<label class="rc-switch__label" tabindex="-1">
<input class="rc-switch__input" type="checkbox" id="changePassword" value="1" checked="{{requirePasswordChange}}"/>
<input class="rc-switch__input" type="checkbox" id="changePassword" value="1" checked="{{requirePasswordChange}}" disabled="{{requirePasswordChangeDisabled}}"/>
<span class="rc-switch__button">
<span class="rc-switch__button-inside"></span>
</span>
Expand Down
21 changes: 21 additions & 0 deletions app/ui-flextab/client/tabs/userEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ Template.userEdit.helpers({
return !Template.instance().user || Template.instance().user.requirePasswordChange;
},

requirePasswordChangeDisabled() {
// when setting a random password, requiring a password change is mandatory
return !Template.instance().user || Template.instance().requiringPasswordReset.get();
},

setRandomPasswordDisabled() {
// when creating a new user, setting a random password is mandatory
return !Template.instance().user;
},

setRandomPassword() {
return !Template.instance().user || Template.instance().user.setRandomPassword;
},
Expand Down Expand Up @@ -86,6 +96,15 @@ Template.userEdit.events({
template.url.set(text);
},

'change #setRandomPassword'(e, template) {
const requiring = e.currentTarget.checked;
template.requiringPasswordReset.set(requiring);

if (requiring) {
$(e.currentTarget.form).find('#changePassword')[0].checked = true;
}
},

'change .js-select-avatar-upload [type=file]'(event, template) {
const e = event.originalEvent || event;
let { files } = e.target;
Expand Down Expand Up @@ -157,6 +176,8 @@ Template.userEdit.onCreated(function() {
this.roles = this.user ? new ReactiveVar(this.user.roles) : new ReactiveVar([]);
this.avatar = new ReactiveVar();
this.url = new ReactiveVar('');
this.requiringPasswordReset = new ReactiveVar(false);

Notifications.onLogged('updateAvatar', () => this.avatar.set());

const { tabBar } = Template.currentData();
Expand Down