Skip to content

Instantly share code, notes, and snippets.

@TiuTalk
Created November 2, 2011 20:45
Show Gist options
  • Save TiuTalk/1334862 to your computer and use it in GitHub Desktop.
Save TiuTalk/1334862 to your computer and use it in GitHub Desktop.
<?php
public function beforeFilter() {
parent::beforeFilter();
// Painel de Controle
if (isset($this->params['prefix']) && $this->params['prefix'] == 'admin') {
$this->layout = 'admin';
// Configuração do AuthComponent
$this->Auth->authError = 'Área restrita';
$this->Auth->sessionKey = 'Auth.Admin';
$this->Auth->authenticate = array('Form' => array(
'fields' => array('username' => 'email'),
'scope' => array('User.status_id' => STATUS_ATIVO)
));
// Painel do Aluno
} elseif (isset($this->params['prefix']) && $this->params['prefix'] == 'aluno') {
// Configuração do AuthComponent
# $this->Auth->authorize = array('Controller');
$this->Auth->authError = 'Área restrita';
$this->Auth->sessionKey = 'Auth.Student';
$this->Auth->loginAction = array('controller' => 'students', 'action' => 'login', 'aluno' => true);
$this->Auth->authenticate = array('Form' => array(
'userModel' => 'Student',
'fields' => array('username' => 'email'),
'scope' => array('Student.status_id' => STATUS_STUDENT_INSCRICAO_CONFIRMADA)
));
// Site externo (fora dos painéis de controle)
} else {
$this->Auth->allow('*');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment