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
27 changes: 24 additions & 3 deletions administrator/components/com_users/src/Model/UserModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ public function getForm($data = array(), $loadData = true)
return false;
}

$user = Factory::getUser();

// If the user needs to change their password, mark the password fields as required
if (Factory::getUser()->requireReset)
if ($user->requireReset)
{
$form->setFieldAttribute('password', 'required', 'true');
$form->setFieldAttribute('password2', 'required', 'true');
Expand All @@ -143,14 +145,33 @@ public function getForm($data = array(), $loadData = true)
$form->setFieldAttribute('language', 'type', 'frontend_language', 'params');
}

$userId = $form->getValue('id');
$userId = (int) $form->getValue('id');

// The user should not be able to set the requireReset value on their own account
if ((int) $userId === (int) Factory::getUser()->id)
if ($userId === (int) $user->id)
{
$form->removeField('requireReset');
}

/**
* If users without core.manage permission editing their own account, remove some fields which they should
* not be allowed to change and prevent them to change user name if configured
*/
if (!$user->authorise('core.manage', 'com_users') && (int) $user->id === $userId)
{
if (!ComponentHelper::getParams('com_users')->get('change_login_name'))
{
$form->setFieldAttribute('username', 'required', 'false');
$form->setFieldAttribute('username', 'readonly', 'true');
$form->setFieldAttribute('username', 'description', 'COM_USERS_USER_FIELD_NOCHANGE_USERNAME_DESC');
}

$form->removeField('lastResetTime');
$form->removeField('resetCount');
$form->removeField('sendEmail');
$form->removeField('block');
}

return $form;
}

Expand Down
1 change: 1 addition & 0 deletions administrator/language/en-GB/com_users.ini
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ COM_USERS_USER_FIELD_FRONTEND_LANGUAGE_LABEL="Frontend Language"
COM_USERS_USER_FIELD_LASTRESET_LABEL="Last Reset Date"
COM_USERS_USER_FIELD_LASTVISIT_LABEL="Last Visit Date"
COM_USERS_USER_FIELD_NAME_LABEL="Name"
COM_USERS_USER_FIELD_NOCHANGE_USERNAME_DESC="If you want to change your Username, please contact a site administrator."
COM_USERS_USER_FIELD_PASSWORD1_MESSAGE="The passwords you entered do not match. Please enter your desired password in the password field and confirm your entry by entering it in the confirm password field."
COM_USERS_USER_FIELD_PASSWORD2_LABEL="Confirm Password"
COM_USERS_USER_FIELD_REGISTERDATE_LABEL="Registration Date"
Expand Down