Skip to content

Instantly share code, notes, and snippets.

@simkimsia
Last active November 28, 2015 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simkimsia/683d877aeac880ccc3b5 to your computer and use it in GitHub Desktop.
Save simkimsia/683d877aeac880ccc3b5 to your computer and use it in GitHub Desktop.
<?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);
}
<?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