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.
Okay, good to know about coding placement. Glad you reminded me about the backup. Thanks for the support!!
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?
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.
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?
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);
Yep, this is exactly what i'm looking for. Thanks for the details.
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.]