<![CDATA[ $modx->runProcessor('security/login', array); - My Forums]]> https://forums.modx.com/thread/?thread=101996 <![CDATA[$modx->runProcessor('security/login', array);]]> https://forums.modx.com/thread/101996/modx--runprocessor-security-login-array#dis-post-549841
I am trying to figure out why I can't automatically log all users into a very low level so I can allow them to all upload. The website is running on an Intranet so security is not so much of an issue. Their user credentials are picked up from a third party login, so the application knows who they are if only they could be logged in.

I have tried to log them in by calling:
$output = $modx->runProcessor('security/login', array(
            'username' => 'xxxxx',
            'password' => 'xxxxx'
        ) 
)


But when I run that in a snippet, I get a 500 server error.

I tried temporarily using the Login Extra to generate a login form and use that. I am not able to log in with that either.

I have also tried creating a separate file are attempting a direct login there:
require_once '/xxxx/xxxxx/xxxxx/config.core.php';
require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->getService('error','error.modError');

$output = $modx->runProcessor('security/login', array(
            'username' => 'xxxxx',
            'password' => 'xxxxx'
        ), array (
            'processors_path' => '/xxxxx/xxxxx/xxxxx/core/model/modx/processors'
        ));
$modx->toJSON($modx->error->failure('Error!'. $output));
print_r($output);



But this does not log the user in either and returns nothing at all.

Any ideas what I am doing wrong? Managers are able to login without a problem. And managers also have privileges in the web context so it seems my contexts and privileges are working correctly.

Thanks
]]>
[email protected] Apr 03, 2017, 10:13 PM https://forums.modx.com/thread/101996/modx--runprocessor-security-login-array#dis-post-549841
<![CDATA[Re: $modx->runProcessor('security/login', array);]]> https://forums.modx.com/thread/101996/modx--runprocessor-security-login-array#dis-post-549933 BobRay Apr 06, 2017, 09:08 PM https://forums.modx.com/thread/101996/modx--runprocessor-security-login-array#dis-post-549933 <![CDATA[Re: $modx->runProcessor('security/login', array);]]> https://forums.modx.com/thread/101996/modx--runprocessor-security-login-array#dis-post-549913
$modx->event->_output = (bool) $authenticated;
return;


As well as trigger a login once authenticated:

$output = $modx->runProcessor('security/login', array(
            'username' => $fullName,
            'password' => $password
        ));
]]>
[email protected] Apr 06, 2017, 07:59 AM https://forums.modx.com/thread/101996/modx--runprocessor-security-login-array#dis-post-549913
<![CDATA[Re: $modx->runProcessor('security/login', array);]]> https://forums.modx.com/thread/101996/modx--runprocessor-security-login-array#dis-post-549843
You might find this three-part series helpful: https://bobsguides.com/blog.html/2016/04/06/bypassing-the-modx-manager-login-i/.

If you want this for the front end, change 'OnManager...' to 'OnWeb...' in the code and in attaching the plugin to events.

Another way to go would be to adapt the plugin in the article to validate the user (to bypass the MODX login) and to log them in in code like this:

$user->addSessionContext('web_or_whatever');


This assumes that you have a valid user object, and you may also have to do something like this:

$modx->user = &$usr;

]]>
BobRay Apr 04, 2017, 02:04 AM https://forums.modx.com/thread/101996/modx--runprocessor-security-login-array#dis-post-549843