Reputation: 246
I've been trying to accomplish this for some time but no results.. I'm using a ion auth in my codeignitor website.
I want to disable ion auth for front end login, and want it to only work for admin side login. is that possible? if yes then how..
my code:
class Login extends MY_Controller {
public function __construct(){
parent::__construct();
$this->load->library('session');
$this->load->helper('url');
require_once APPPATH.'vendor/autoload.php';
}
public function index(){
$this->render('login');
}
}
This generates below error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI::$ion_auth
Filename: MX/Controller.php
Line Number: 59
Backtrace:
File: D:\xampp\htdocs\moneyclues2\application\third_party\MX\Controller.php
Line: 59
Function: _error_handler
File: D:\xampp\htdocs\moneyclues2\application\core\MY_Controller.php
Line: 126
Function: __get
File: D:\xampp\htdocs\moneyclues2\application\core\MY_Controller.php
Line: 59
Function: _setup
File: D:\xampp\htdocs\moneyclues2\application\controllers\Login.php
Line: 7
Function: __construct
File: D:\xampp\htdocs\moneyclues2\index.php
Line: 316
Function: require_once
when I extend CI_controller. I got below error for render method
Fatal error: Call to undefined method Login::render() in D:\xampp\htdocs\moneyclues2\application\controllers\Login.php on line 15
A PHP Error was encountered
Severity: Error
Message: Call to undefined method Login::render()
Filename: controllers/Login.php
Line Number: 15
Backtrace:
Upvotes: 1
Views: 1561
Reputation: 9265
You need to load the Ion_Auth
library! $this->load->library('ion_auth');
But if you want it to only be in use for admin-related stuff just make two different MY
controllers in core
and have your public and admin controllers extend them. Don't autoload Ion_Auth
if you only use it in 1/2 of your website.
class MY_Public_Controller extends CI_Controller {
public function __construct() {
parent::__construct();
// load what you need here
}
}
class MY_Admin_Controller extends CI_Controller {
public function __construct() {
parent::__construct();
// load what you need here
$this->load->database();
$this->load->library('session');
$this->load->library('ion_auth');
}
}
Example admin controller:
class Somecontroller extends MY_Admin_Controller {
public function index() {
}
}
Upvotes: 0
Reputation: 246
adding ion_auth library $autoload['libraries'] = array('database','ion_auth');
to autoload.php
worked for me.
and extended MY_Controller in in place of CI_Controller.
Upvotes: 1