-
-
Save tigrang/2051470 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'; | |
AuthComponent::$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'; | |
AuthComponent::$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