We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53932
    • 33 Posts
    I have edited the core code that made worked!! Thanks!!

    if ($profile->get('blocked')) {
         if ($this->user->passwordMatches($this->givenPassword)) {
              return $this->modx->lexicon('login_blocked_admin');
         }  else {   
              return $this->modx->lexicon('login_username_password_incorrect');
         }
    }
    

    [ed. note: rajani last edited this post 8 years, 8 months ago.]
      • 3749
      • 24,544 Posts
      I'm glad you sorted it. FYI, if you put your code in code tags (<> on the toolbar), it will be easier to read and sometimes more accurate.

      if ($profile->get('blocked')) {
          if ($this->user->passwordMatches($this->givenPassword)) {
              return $this->modx->lexicon('login_blocked_admin');
          } else { 
              return $this->modx->lexicon('login_username_password_incorrect');
          }
      }
      
      


      You probably know this, but your code may be overwritten any time you upgrade or re-install MODX, so you might want to create a backup of the edited file.
        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
        Okay, good to know about coding placement. Glad you reminded me about the backup. Thanks for the support!!
          • 53932
          • 33 Posts
          To avoid overwriting the modified script upon upgrades, I'm working on writing a custom script and trying to extend the login class to my custom login class. During this process, I got a question.
          'modSecurityLoginProcessor' class has actual blocked logic for user before he login's and there is main 'Login' class. so my question now is, how does 'modSecurityLoginProcessor' class calling in 'Login' class? I don't see 'modSecurityLoginProcessor' class called any where from login. Can you please provide me the how/where this function getting called?
            • 3749
            • 24,544 Posts
            I assume we're talking about logging in to the Manager.

            As I understand it, going to the login page launches the login controller: manager\controllers\default\security\login.class.php

            Login is handled there by the handleLogin() function.

            The handleLogin() function calls the login processor, which actually validates the user and logs them in by creating the sessionContext.

            In the processor, there is an OnBeforeManagerLogin event called before anything else happens. The given username and password are sent to any events attached to it, so you could look for the user yourself and if they're not there, you could set/or update a $_SESSION variable with the number of failed logins, but offhand, I don't see how you could display it.

            It occurs to me that you might be able do it with JavaScript in an onReady() function that looked for the "your credentials are wrong" message and set a variable in sessionStorage or a cookie, then popped up an alert of when the variable reached the limit.
              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
              This is for logging into the user access site. I'm trying to customize the login class using snippet by extending the MODX login class and customize the code from the method checkIsBlocked(). so trying to find relation/how to invoke this method which is defined in different class(security/login.class.php).

              checkIsBlocked() method which is defined in 'model/modx/processors/security/login.class.php' class (class modSecurityLoginProcessor extends modProcessor ) .

              How the modSecurityLoginProcessor is get invoked by Login (packages/login) class?
                • 3749
                • 24,544 Posts
                It sounds like you mean in the front end using the code in the Login extra.

                That processor is called in the core\components\login\controllers\web\Login.php file (on line 251 -- the last line of the code below -- in the version I have).


                 $c = array(
                    'login_context' => $this->getProperty('loginContext'),
                    'add_contexts' => $this->getProperty('contexts',''),
                    'username' => $fields['username'],
                    'password' => $fields['password'],
                    'returnUrl' => $fields['returnUrl'],
                    'rememberme' => !empty($fields[$this->getProperty('rememberMeKey','rememberme')]) ? true : false,
                 );
                
                return $this->modx->runProcessor('security/login',$c); 
                  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, this is exactly what i'm looking for. Thanks for the details.
                    • 53932
                    • 33 Posts
                    I have tried using this in my custom class as shown below but it resulting the null string. Not sure what else is missing. Please suggest.

                    $output['loginRes'] = $modx->runProcessor('security/login', array(
                                 'username' => 'newUser', 
                                 'password' => 'JCvVbcGp'
                             ), array (
                                 'processors_path' => '/Applications/MAMP/core/model/modx/processors'
                             ));
                            
                     var_dump($output['loginRes']);

                    [ed. note: rajani last edited this post 8 years, 8 months ago.]
                      • 3749
                      • 24,544 Posts
                      FYI, if you wrap your code in code tags ( <> on the menu bar), it will be much easier to read.

                      It looks like the processors path goes in the *third* argument to runProcessor():


                      $userData = array(
                         'username' => 'newUser', 
                         'password' => 'JCvVbcGp',
                      }
                      
                      $options = array(
                         'processors_path' => '/Applications/MAMP/core/model/modx/processors/',
                      );
                      
                      $output['loginRes'] = $modx->runProcessor('security/login', $userData, $options);
                      
                      
                      var_dump($output['loginRes']);
                      [ed. note: BobRay last edited this post 8 years, 8 months ago.]
                        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