Skip to content

Commit

Permalink
Allow authenticator's unauthenticated() method to return response.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Apr 29, 2014
1 parent f247c9d commit 4906816
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/Controller/Component/Auth/BaseAuthenticate.php
Expand Up @@ -201,9 +201,12 @@ public function getUser(Request $request) {
}

/**
* Handle unauthenticated access attempt. In implementation, will return true to indicate
* the unauthenticated request has been dealt with and no more action is required by
* AuthComponent or void (default).
* Handle unauthenticated access attempt. In implementation valid return values
* can be:
*
* - Null - No action taken, AuthComponent should return appropriate response.
* - Cake\Network\Response - A response object, which will cause AuthComponent to
* simply return that response.
*
* @param \Cake\Network\Request $request A request object.
* @param \Cake\Network\Response $response A response object.
Expand Down
5 changes: 3 additions & 2 deletions src/Controller/Component/AuthComponent.php
Expand Up @@ -299,8 +299,9 @@ protected function _unauthenticated(Controller $controller) {
$this->constructAuthenticate();
}
$auth = $this->_authenticateObjects[count($this->_authenticateObjects) - 1];
if ($auth->unauthenticated($this->request, $this->response)) {
return false;
$result = $auth->unauthenticated($this->request, $this->response);
if ($result !== null) {
return $result;
}

if ($this->_isLoginAction($controller)) {
Expand Down

0 comments on commit 4906816

Please sign in to comment.