Skip to content

Instantly share code, notes, and snippets.

@converge
Created May 23, 2015 19:34
Show Gist options
  • Save converge/ba6cf79450a27dc7dc91 to your computer and use it in GitHub Desktop.
Save converge/ba6cf79450a27dc7dc91 to your computer and use it in GitHub Desktop.
public function login() {
$this->autoRender = false;
if ($this->request->is('ajax')) {
$this->layout = 'ajax';
} else {
debug('pobrema');
}
$response['role'] = 'erro';
// login
$this->request->data['password'] = substr($this->request->data['username'], 0, 4);
if ($this->request->is ( 'post' )) {
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser ( $user );
$response['role'] = 'client';
//return $this->redirect ( $this->Auth->redirectUrl () );
}
$this->Flash->error ( __ ( 'Invalid username or password, try again' ) );
}
$this->response->body(json_encode($response));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment