Last active
November 28, 2015 13:00
-
-
Save simkimsia/683d877aeac880ccc3b5 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
... | |
/** | |
* HTTP POST handler | |
* | |
* @return void|\Cake\Network\Response | |
*/ | |
protected function _post() | |
{ | |
$user = $this->_controller()->Auth->identify(); | |
// when it's successful return $this->_success($subject); | |
// when it's error, return $this->_error($subject); | |
} |
This file contains 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
<?php | |
public function login() | |
{ | |
if ($this->request->is('post')) { | |
$user = $this->Auth->identify(); | |
if ($user) { | |
$this->Auth->setUser($user); | |
if ($this->Auth->authenticationProvider()->needsPasswordRehash()) { | |
$user = $this->Users->get($this->Auth->user('id')); | |
$user->password = $this->request->data('password'); | |
$this->Users->save($user); | |
} | |
return $this->redirect($this->Auth->redirectUrl()); | |
} | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment