[eluser]danmontgomery[/eluser]
Generally speaking, I would put all redirect logic in the controller. But you can access the CI object with get_instance(), and check the class name with get_class().
Code:
$CI = get_instance();
$class_name = get_class($CI);
Rather than checking the class name, I would set a class variable to check (again, keeping the redirect logic in the controller):
Code:
class MY_Controller extends CI_Controller {
protected $_require_login = FALSE;
public function __construct() {
parent::__construct();
if($this->_require_login == TRUE && !$this->some_auth->logged_in()) {
redirect('login');
exit();
}
}
}
// ...
class Example_controller extends MY_Controller {
protected $_require_login = TRUE;
}
// ...
class Login_controller extends MY_Controller {
protected $_require_login = FALSE;
}