1
I’m doing an admin here who blows their pages. I know how to allow them to be accessed only after login, but I don’t know if the way I’m doing it is the right way. Look at the 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 the action and do 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: I need to check with the Auth::instance()->get_user()
in all actions that will be called within the template or has some way to protect all actions without having to do this? There is the possibility to do this in the template itself?