Skip to content

Instantly share code, notes, and snippets.

@TiuTalk
Last active December 17, 2015 18:39
Show Gist options
  • Save TiuTalk/5654740 to your computer and use it in GitHub Desktop.
Save TiuTalk/5654740 to your computer and use it in GitHub Desktop.
<?php
App::uses('Controller', 'Controller');
class AppController extends Controller {
public $components = array('Session', 'Auth');
public function isPrefix($prefix) {
return isset($this->request->params['prefix']) && $this->request->params['prefix'] == $prefix;
}
public function beforeFilter() {
$this->Auth->authenticate = array('Form' => array(
'userModel' => 'Funcionario',
'fields' => array(
'username' => 'nome',
'password' => 'senha'
)
));
$this->Auth->loginAction = array(
'controller' => 'funcionarios',
'action' => 'login',
'admin' => false
);
if ($this->action == 'login') {
$this->layout = 'login';
}
if ($this->isPrefix('admin')) {
$this->layout = 'admin';
} else {
$this->Auth->allow();
}
parent::beforeFilter();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment