It's getting me null output. Not sure why.
output: string(0) ""
One more question, Is there a way to trigger an email to user as soon as user account gets blocked?
My bad, the processors path should end in a slash.
There's no easy way to trigger an email.
I would put the email code in your controller, or wherever you can figure out that the user has been blocked.
Something like this:
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->set(modMail::MAIL_BODY, 'Some message');
$modx->mail->set(modMail::MAIL_FROM, '[email protected]');
$modx->mail->set(modMail::MAIL_FROM_NAME, 'Your Name');
$modx->mail->set(modMail::MAIL_SENDER, '[email protected]');
$modx->mail->set(modMail::MAIL_SUBJECT, 'Some Subject');
$modx->mail->address('to', '[email protected]', 'UserName');
$modx->mail->address('reply-to', '[email protected]');
$modx->mail->setHTML(true);
$sent = $modx->mail->send();
if ($sent) {
$output = 'Mail Sent';
} else {
$output = 'Mail Not Sent';
}
return $output;
Yes, until they log in with the correct credentials, MODX has no idea who they are. You could try a search for users with the same username. If that works, you can get the email address, but if a hacker guesses a username, you've got a problem. It's not really practical to look for users with a similar password.
Until a successful login, they are the (anonymous) user and that user gets blocked after too many failed login attempts, but that user has no user profile -- so no email address.
Also, sending an email that contained a new password any time someone made a few failed login attempt would create a pretty significant security vulnerability.
You might do what some sites do, which is to have two separate pages (with links that show up on the Login form after x number of failed logins), one for "Forgot Username" and another for "Forgot Password." On those pages, you'd have a form that let them enter what they know and check the database for matches - then send the email. It's still something of a security problem, so the more information you have on the form (state, phone, zip, email, username, etc.) the better.
Yes, agreed.
As current system is saying that when user gets blocked - user blocked by manager by admin. To avoid contacting admin for unblocking user alternatively, would want to send an activation(unblocked) link thru email in custom class instead of modifying the MODX core files (to avoid losing content during upgrades).
1. For this, can I overwrite the language context for blocked user in a 'custom file' instead MODX lexicon file?
2. FYI - After placing the slash at the end of processors path, it's giving "<" as output. Not sure what else i'm missing there.
If what the user actually sees on the final bad login is 'You have been blocked from the manager by an administrator.'
I might work to modify the lexicon entry by going to System (gear icon) -> Lexicons, namespace: core, topic:login, and changing that message to:
That will survive upgrades to MODX.
Then write your own snippet to send whatever email you want. *But* how will you find the user when the credentials are wrong, and how will you make sure the user is not some hacker randomly trying usernames and emails?
Post some of your code with the processors path.
You're welcome.