I'm building my first project in Codeigniter, using Tank_auth to handle my CMS authentication.
It's working ok but I have a question about best practices. Currently, every function in every controller has the following structure:
public function add()
{
if ($this->tank_auth->is_logged_in())
{
$data['stuff'] = 'stuff';
$this->load->view('admin/cms_add',$data);
} else
{
redirect('/admin/login/');
}
}
With quite a few controllers, and a few functions in each, it's starting to get repetitive, and I wonder if this is the correct way to go about it, or if there's a cleaner method of ensuring non-logged in users can't access these functions.
Thanks in advance.