Skip to content

Commit

Permalink
MACF-26: Fix auto-generation of password on user update (#108)
Browse files Browse the repository at this point in the history
* Generate password only when user is created

* Track password update to set when actually updated
  • Loading branch information
joristirado authored Apr 27, 2020
1 parent 698b1b4 commit bd3b034
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions submodules/user/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,13 @@ define(function(require) {
});
});

user_html.find('#pwd_mngt_pwd1').on('keyup', function(event) {
event.preventDefault();

user_html.find('#was_password_updated').prop('checked', 'checked');
user_html.find('#pwd_mngt_pwd2').val('');
});

$(user_html).delegate('.enabled_checkbox', 'click', function() {
self.userUpdateSingleDevice($(this), user_html);
});
Expand Down Expand Up @@ -1012,12 +1019,13 @@ define(function(require) {
delete form_data.hotdesk.pin;
}

if (form_data.pwd_mngt_pwd1 !== 'fakePassword') {
if (form_data.was_password_updated) {
form_data.password = form_data.pwd_mngt_pwd1;
}

delete form_data.pwd_mngt_pwd1;
delete form_data.pwd_mngt_pwd2;
delete form_data.was_password_updated;
delete form_data.extra;

return form_data;
Expand Down Expand Up @@ -1101,7 +1109,7 @@ define(function(require) {
delete data.timezone;
}

if (!_.has(data, 'password')) {
if (!_.has(data, 'password') && !_.has(data, 'id')) {
data.password = monster.util.randomString(8, 'safe');
}

Expand Down
1 change: 1 addition & 0 deletions submodules/user/views/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ <h3>{{ i18n.callflows.user.queue_options }}</h3>
<label for="pwd_mngt_pwd1">{{ i18n.callflows.user.new_password }}</label>
<div class="input">
<input class="span4" id="pwd_mngt_pwd1" name="pwd_mngt_pwd1" type="password" value="fakePassword"/>
<input class="hidden" id="was_password_updated" name="was_password_updated" type="checkbox">
</div>
</div>

Expand Down

0 comments on commit bd3b034

Please sign in to comment.