Skip to content

Instantly share code, notes, and snippets.

@waltergalvao
Created June 18, 2012 02:25
Show Gist options
  • Save waltergalvao/2946467 to your computer and use it in GitHub Desktop.
Save waltergalvao/2946467 to your computer and use it in GitHub Desktop.
<?php
class UsersController extends AppController {
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allowedActions = array('login','logout','home','index');
}
public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Login ou Senha inválidos. Tente novamente!'));
}
}
}
public function logout() {
$this->redirect($this->Auth->logout());
}
public function registrar() {
$isPost = $this->request->is('post');
if ($isPost && !empty($this->request->data)) {
if ($this->User->save($this->request->data)) {
$this->Session->setFlash('Cadastrado com sucesso','msg-good');
}
}
}
/*public function login() {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash('Dados incorretos','msg-evil');
}
}
public function logout() {
$this->redirect($this->Auth->logout());
}*/
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment