Welcome Guest, Not a member yet? Register   Sign In
Joomla authentication in CodeIgniter

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.

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('..'));

   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');
   $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 />');
  } 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.
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.

If you want that then use Joomla. This is a CodeIgniter forum not Joomla...


[quote author="InsiteFX" date="1333788375"]If you want that then use Joomla. This is a CodeIgniter forum not Joomla...


Thanks for reply, I'm developing Codeigniter application. I need this part of joomla only for authentication in my CI application. But I found that error occurred in core/CodeIgniter.php after I put some script to load environment from Joomla, therefore I think went to this forum is ok. But thanks again for advise, I'll look at Joomla also to find the solution.

Theme © iAndrew 2016 - Forum software by © MyBB