We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53932
    • 33 Posts
    Hi,

    Is there any parameter to see the value of number login attempts made before the user logins into the system? or How do we know user got blocked before enter/login into the system?

    This question has been answered by rajani. See the first response.

      • 3749
      • 24,544 Posts
      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.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 53932
        • 33 Posts
        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.]
          • 3749
          • 24,544 Posts
          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.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 53932
            • 33 Posts
            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.
              • 3749
              • 24,544 Posts
              It doesn't show a message even if the user tries to log in again?
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 53932
                • 33 Posts
                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
                  • 53932
                  • 33 Posts
                  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!!
                    • 53932
                    • 33 Posts
                    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.]
                      • 3749
                      • 24,544 Posts
                      I don't think there's any way to do that without hacking the core code. I could be wrong.
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting