Created
May 23, 2015 19:34
-
-
Save converge/ba6cf79450a27dc7dc91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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