Skip to content

Commit

Permalink
Clarify message when changing user passwords (#16502)
Browse files Browse the repository at this point in the history
### Why is it needed?
When you change passwords for several users, it is not always clear
which user's password was changed. The user's login and password are not
visible.


![user_before](https://github.com/modxcms/revolution/assets/12523676/da976af8-d489-4a40-8bcb-1acece6c084d)


![user_after](https://github.com/modxcms/revolution/assets/12523676/d38a55d8-ea21-4682-94f0-49bedb6f0cac)

### Related issue(s)/PR(s)
N\A
  • Loading branch information
Ruslan-Aleev authored and opengeek committed Feb 16, 2024
1 parent ae2ca75 commit 3bbd1ba
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
6 changes: 3 additions & 3 deletions core/lexicon/en/user.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
$_lang['user_blockeduntil_desc'] = 'If set, the user will be blocked until this time.';
$_lang['user_changeddata'] = 'Your data has been changed. Please log in again.';
$_lang['user_class_key_desc'] = 'The MODX Class Key for this user. Do not change this unless you know what you are doing.';
$_lang['user_created_password_message'] = 'The User has been created. The password is: [[+password]]';
$_lang['user_created_password_message'] = 'The User <b>[[+username]]</b> has been created. <br>The password is: <b>[[+password]]</b>';
$_lang['user_confirm_remove'] = 'Are you sure you want to permanently delete this user?';
$_lang['user_country'] = 'Country';
$_lang['user_dob'] = 'Date of birth';
Expand Down Expand Up @@ -165,7 +165,7 @@
$_lang['user_male'] = 'Male';
$_lang['user_management_msg'] = 'Here you can choose which user you wish to edit.';
$_lang['user_mobile'] = 'Mobile phone number';
$_lang['user_password_changed'] = 'Password successfully changed to: [[+password]]';
$_lang['user_password_changed'] = 'Password successfully changed to: <b>[[+password]]</b>';
$_lang['user_phone'] = 'Phone number';
$_lang['user_photo'] = 'User Photo';
$_lang['user_photo_message'] = 'Enter the image URL for this user or use the insert button to select or upload an image file on the server.';
Expand All @@ -186,7 +186,7 @@
$_lang['user_sudo_desc'] = 'If checked, this user will have full access to all the site and will bypass any Access Permissions checks. *DO NOT* check this unless you mean to do so!';
$_lang['user_title'] = 'Create/Edit user';
$_lang['user_other'] = 'Other';
$_lang['user_updated_password_message'] = 'The User has been updated. The password is: [[+password]]';
$_lang['user_updated_password_message'] = 'The User <b>[[+username]]</b> has been updated. <br>The password is: <b>[[+password]]</b>';
$_lang['user_upload_message'] = 'If you wish to stop this user uploading any filetypes in this category, make sure that the \'Use Main Configuration Setting\' checkbox is not ticked and leave the field blank.';
$_lang['user_use_config'] = 'Use System Configuration Setting';
$_lang['user_username_desc'] = 'The unique identifier of this User, and the name by which they will login to the site.';
Expand Down
15 changes: 8 additions & 7 deletions core/src/Revolution/Processors/Security/User/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public static function getInstance(modX $modx,$className,$properties = []) {
public function initialize() {
$this->setDefaultProperties(
[
'class_key' => $this->classKey,
'blocked' => false,
'active' => false,
'class_key' => $this->classKey,
'blocked' => false,
'active' => false,
]
);
$this->classKey = $this->getProperty('class_key', modUser::class);
Expand Down Expand Up @@ -124,10 +124,10 @@ public function setUserGroups()
$membership = $this->modx->newObject(modUserGroupMember::class);
$membership->fromArray(
[
'user_group' => $group['usergroup'],
'role' => $group['role'],
'member' => $this->object->get('id'),
'rank' => isset($group['rank']) ? $group['rank'] : $idx
'user_group' => $group['usergroup'],
'role' => $group['role'],
'member' => $this->object->get('id'),
'rank' => isset($group['rank']) ? $group['rank'] : $idx
]
);
if (empty($group['rank'])) {
Expand Down Expand Up @@ -242,6 +242,7 @@ public function cleanup() {
$passwordNotifyMethod = $this->getProperty('passwordnotifymethod', 's');
if (!empty($passwordNotifyMethod) && $passwordNotifyMethod == 's') {
return $this->success($this->modx->lexicon('user_created_password_message', [
'username' => $this->object->get('username'),
'password' => $this->newPassword,
]), $this->object);
} else {
Expand Down
39 changes: 20 additions & 19 deletions core/src/Revolution/Processors/Security/User/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ public function checkActiveChange() {
if ($this->activeStatusChanged) {
$event = $this->newActiveStatus == true ? 'OnBeforeUserActivate' : 'OnBeforeUserDeactivate';
$OnBeforeUserActivate = $this->modx->invokeEvent($event,
[
'id' => $this->object->get('id'),
'user' => &$this->object,
'mode' => modSystemEvent::MODE_UPD,
]
[
'id' => $this->object->get('id'),
'user' => &$this->object,
'mode' => modSystemEvent::MODE_UPD,
]
);
$canChange = $this->processEventResponse($OnBeforeUserActivate);
if (!empty($canChange)) {
Expand Down Expand Up @@ -208,8 +208,8 @@ public function setUserGroups() {
$existingGroup = $currentGroups[$existingMembership->get('user_group')];
$existingMembership->fromArray(
[
'role' => $existingGroup['role'],
'rank' => isset($existingGroup['rank']) ? $existingGroup['rank'] : 0
'role' => $existingGroup['role'],
'rank' => isset($existingGroup['rank']) ? $existingGroup['rank'] : 0
]
);
$remainingGroupIds[] = $existingMembership->get('user_group');
Expand All @@ -233,10 +233,10 @@ public function setUserGroups() {
$membership = $this->modx->newObject(modUserGroupMember::class);
$membership->fromArray(
[
'user_group' => $newGroup['usergroup'],
'role' => $newGroup['role'],
'member' => $this->object->get('id'),
'rank' => isset($newGroup['rank']) ? $newGroup['rank'] : $idx
'user_group' => $newGroup['usergroup'],
'role' => $newGroup['role'],
'member' => $this->object->get('id'),
'rank' => isset($newGroup['rank']) ? $newGroup['rank'] : $idx
]
);
if (empty($newGroup['rank'])) {
Expand Down Expand Up @@ -297,11 +297,11 @@ public function afterSave() {
public function fireAfterActiveStatusChange() {
$event = $this->newActiveStatus == true ? 'OnUserActivate' : 'OnUserDeactivate';
$this->modx->invokeEvent($event,
[
'id' => $this->object->get('id'),
'user' => &$this->object,
'mode' => modSystemEvent::MODE_UPD,
]
[
'id' => $this->object->get('id'),
'user' => &$this->object,
'mode' => modSystemEvent::MODE_UPD,
]
);
}

Expand All @@ -321,9 +321,10 @@ public function cleanup()
$passwordNotifyMethod = $this->getProperty('passwordnotifymethod');
if (!empty($passwordNotifyMethod) && !empty($this->newPassword) && $passwordNotifyMethod == 's') {
return $this->success($this->modx->lexicon('user_updated_password_message',
[
'password' => $this->newPassword,
]
[
'username' => $this->object->get('username'),
'password' => $this->newPassword,
]
), $this->object);
} else {
return $this->success('',$this->object);
Expand Down

0 comments on commit 3bbd1ba

Please sign in to comment.