I'm doing an admin here that loads its pages in the middle. I know how to allow them to be accessed only after login, but I do not know if the way I'm doing is the correct mode. See Template:
class Controller_Administracao extends Controller_Template {
//put your code here
public $template = 'template_admin';
public function before() {
parent::before();
if($this->auto_render){
$this->template->content = '';
}
}
public function after() {
parent::after();
}
}
So far so good, here I call action and make her "protection":
public function action_home(){
//Aqui uso o Auth do Kohana, está tudo normal
//Se não estiver feito o login, volta para a tela inicial
$user = Auth::instance()->get_user();
if(!$user){
$this->redirect('/');
}
//Feito o login, vai para o Dashboard
else{
$this->template->content = View::factory('admin/default');
}
}
My question is: Do I need to check with Auth::instance()->get_user()
on all actions that will be called within the template or have some way to protect all actions without having to do this verification? Is it possible to do this in the template itself?