I'm not sure exactly what you're after, but maybe this will help answer your question:
The failed_login_attempts System Setting sets the number of login tries before the user is blocked.
This code will tell if the user is blocked:
if ($modx->user->get('blocked')) {
/* user is blocked */
}
MODX stores the number of failed attempts in an extra field of the user profile: failedlogincount. It's not a 'real' profile field, so I don't think it's available to you. As far as I can tell, the user profile is not sent to any of the login events, just the user object. You can get the user profile for that user with $user->getOne('Profile'), but I think that would get the profile from the DB and it would not include the failedlogincount field.
Unfortunately, there is no OnFailedLogin event.
Thanks for the reply Bob. Here is the more context to my question:
If user attempts to login with wrong username & password more than what we set for 'failed_login_attempts System Setting' then we were displaying an error message to user. Now, I want to inform the user that 'user is blocked' when number of wrong attempts reaches the 'failed_login_attempts System Setting'. Any thoughts?
Could you also please let me know in what file we are actually doing this logic of 'blocking user' based on the given 'failed_login_attempts System Setting'.
[ed. note: rajani last edited this post 8 years, 8 months ago.]
I haven't tested lately, but AFAI, MODX will set the user as blocked when they hit the limit and show them a message telling them that they are blocked on their next attempt.
The message shown is in the login_blocked_too_many_attempts lexicon setting.
I can see that the user got blocked in the Database and on the system settings but it's getting any message to the user on the screen. So trying to show a message to user on web page.
It doesn't show a message even if the user tries to log in again?
Yep, it's not showing that user got blocked on web page. There is some custom code in between. So I trying to do some custom editing (blocked notification) for blocked user as well.
discuss.answer
I have tried with the modx error login template, now it's showing that the user got blocked by the administrator. Thanks for your inputs!!
Hello again,
Slight change in the scenario: Currently, user will get notified when the account got blocked. But would like to inform the user that got blocked when:
- user attempts to enter correct password after entering the wrong passwords 'n' number of times(more than account gets blocked).
Any thoughts?
[ed. note: rajani last edited this post 8 years, 8 months ago.]
I don't think there's any way to do that without hacking the core code. I could be wrong.