I came across this whilst testing another PR:
In Users: Edit, the toolbar shows Send Activation Reminder for a user who is blocked and has never logged in. Clicking it sends the mail "Your account has been activated by an administrator. You can now login …", but the account stays blocked and the login is denied.
Steps to reproduce
Account activated for at
Hello ,
Your account has been activated by an administrator. You can now login at using the username and the password you chose while registering.
6.2
No Send Activation Reminder for a blocked user without a pending activation. An admin blocked this account on purpose, so there is nothing to remind the user of. The "account activated" mail is not sent.
The button is shown and the mail says the account is activated and the user can log in. The account is still blocked.
Joomla 6.3.0-alpha1-dev (same code in 6.2-dev), PHP 8.3, MariaDB 11.8.
The button is shown when activation is not empty or lastvisitDate is NULL (administrator/components/com_users/src/View/User/HtmlView.php, around line 199). block is not checked. UserModel::activate() uses the same condition to send the mail.
Possible fix (tested: no button for the blocked user, a direct user.active request sends no mail, a never-logged-in active user still gets the button):
--- a/administrator/components/com_users/src/View/User/HtmlView.php
+++ b/administrator/components/com_users/src/View/User/HtmlView.php
- $userIsNotActive = !empty($this->item->activation) || \is_null($this->item->lastvisitDate);
+ $userIsNotActive = !empty($this->item->activation) || (\is_null($this->item->lastvisitDate) && !$this->item->block);
--- a/administrator/components/com_users/src/Model/UserModel.php
+++ b/administrator/components/com_users/src/Model/UserModel.php
if (empty($table->activation)) {
- if (\is_null($table->lastvisitDate)) {
+ if (\is_null($table->lastvisitDate) && !$table->block) {
$sendMailTo($prevUserData);
}Blocked users with a pending activation (activation not empty) still get Activate & Send Email, which unblocks them. The fix doesn't touch that path (not tested here).
| Labels |
Added:
No Code Attached Yet
bug
|
||
| Title |
|
||||||
yes this seems to be a perfectly sensible proposal