[eluser]Unknown[/eluser]
Hi All,
I would to create authentication function in CI based on Joomla users that have been registered in separate application. to perform this, I need to define joomla framework environment and call some of its functions in my CI function as simply as follow.
Code:
public function authenticate() {
$username = $this->input->post('txtusername');
$password = $this->input->post('txtpassword');
if($username != '' && $password != '') {
if($this->appvar['authenticationmethod'] == "joomla"){
define( '_JEXEC', 1 );
define('JPATH_BASE', realpath('..'));
define( 'DS', DIRECTORY_SEPARATOR );
require_once (JPATH_BASE .DS. 'includes' .DS. 'defines.php');
require_once (JPATH_BASE .DS. 'includes' .DS. 'framework.php');
require_once (JPATH_BASE .DS. 'libraries' .DS. 'joomla'. DS. 'user' .DS. 'authentication.php');
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$credentials = array(
'username' => $username,
'password' => $password);
$options = array();
$authenticate = JAuthentication::getInstance();
$response = $authenticate->authenticate($credentials, $options);
if ($response->status === JAUTHENTICATE_STATUS_SUCCESS) {
echo('<br />It works<br />');
}
var_dump($response);
} else {
//other way of authentication
}
}
Unfortunately, I found following error when I run it.
Quote:Severity: Notice
Message: Undefined variable: BM
Filename: core/CodeIgniter.php
Line Number: 345
After went checking, seems that the problem occurred when the following line is executed.
Code:
require_once (JPATH_BASE .DS. 'includes' .DS. 'framework.php');
am I doing right up there ? I'm not really sure what happened.
please somebody help me, your advise are much appreciated.