Skip to content

Instantly share code, notes, and snippets.

@tigrang
Forked from TiuTalk/gist:1334862
Created March 16, 2012 17:54
Show Gist options
  • Save tigrang/2051470 to your computer and use it in GitHub Desktop.
Save tigrang/2051470 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';
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