Skip to content

Instantly share code, notes, and snippets.

@hugofabricio
Created November 9, 2013 12:53
Show Gist options
  • Select an option

  • Save hugofabricio/7385138 to your computer and use it in GitHub Desktop.

Select an option

Save hugofabricio/7385138 to your computer and use it in GitHub Desktop.
/**
* Painel Login
*/
public function painel_login()
{
$this->Session->delete('auth_user');
$user = $this->Auth->user();
if(!empty($user)):
$this->redirect($this->Auth->redirect());
endif;
if ($this->request->is('post')) {
if ($this->Auth->login()) {
if ((int)$this->request->data['User']['remember_me'] == 0){
$this->Cookie->delete('AutoLoginUser');
}else{
$this->Cookie->write('AutoLoginUser', $this->Auth->user(), true, '+2 weeks');
}
// Set last login
/*
$this->User->id = $this->Auth->user('id');
$this->User->saveField('last_login', date('Y-m-d H:i:s'));
*/
$this->redirect($this->Auth->redirectUrl());
} else {
$this->Session->setFlash(__('Usuário ou senha inválidos, tente novamente.'), DANGER);
}
}
// Set
$this->set(
'title_for_layout', 'Acessar'
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment