Is this possible?
I am trying to validate and pull content from modx entirely via the API. The login snippet is really causing trouble for a simple task of validating a user. I'm looking for a way to do a "simple" mysql lookup based on provided credentials.
if ( valid )
{
echo 'success';
}
else
{
echo 'fail';
}
Another thing I am curious about...I have chased the actual login snippet down to this function:
public function redirectAfterLogin(modProcessorResponse $response)
{
$responseArray = $response->getObject();
/* allow dynamic redirection handling */
$redirectBack = $this->modx->getOption('redirectBack',$_REQUEST,$this->getProperty('redirectBack',''));
$redirectBackParams = $this->modx->getOption('redirectBackParams',$_REQUEST,$this->getProperty('redirectBackParams',''));
if ( !empty($redirectBackParams) )
{
$redirectBackParams = $this->login->decodeParams($redirectBackParams);
}
/* otherwise specify a specific resource to redirect to */
$loginResourceId = $this->getProperty('loginResourceId',$redirectBack);
/* login posthooks succeeded, now redirect */
if ( !empty($loginResourceId) )
{
$loginResourceParams = $this->getProperty('loginResourceParams',$redirectBackParams);
if ( !empty($loginResourceParams) && !is_array($loginResourceParams) )
{
$loginResourceParams = $this->modx->fromJSON($loginResourceParams);
}
$url = $this->modx->makeUrl($loginResourceId,'',$loginResourceParams,'full');
$this->modx->sendRedirect($url);
}
elseif ( !empty($responseArray) && !empty($responseArray['url']) )
{
$this->modx->sendRedirect($responseArray['url']);
}
else
{
// $this->modx->sendRedirect($this->modx->getOption('site_url'));
error_log( 'USERNAME: '.$this->modx->user('username') );
}
}
The output on my error log is: PHP Fatal error: Call to undefined method modX::user()
I am successfully logging in... why is it that modx doesn't have access to the user at this point?
[ed. note: jentree last edited this post 14 years, 4 months ago.]