Skip to content

Commit

Permalink
Extract method for easier extension/overwriting.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Oct 13, 2016
1 parent f71b823 commit 0b9fcb3
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/Controller/Component/AuthComponent.php
Expand Up @@ -402,10 +402,7 @@ protected function _unauthenticated(Controller $controller)
*/
protected function _loginActionRedirectUrl()
{
$urlToRedirectBackTo = $this->request->here(false);
if (!$this->request->is('get')) {
$urlToRedirectBackTo = $this->request->referer(true);
}
$urlToRedirectBackTo = $this->_getUrlToRedirectBackTo();

$loginAction = $this->_config['loginAction'];
if ($urlToRedirectBackTo === '/') {
Expand Down Expand Up @@ -999,4 +996,22 @@ public function authorizationProvider()
{
return $this->_authorizationProvider;
}

/**
* Returns the URL to redirect back to or / if not possible.
*
* This method takes the referrer into account as long as the
* request is of type GET.
*
* @return string
*/
protected function _getUrlToRedirectBackTo()
{
$urlToRedirectBackTo = $this->request->here(false);
if (!$this->request->is('get')) {
$urlToRedirectBackTo = $this->request->referer(true);
}

return $urlToRedirectBackTo;
}
}

0 comments on commit 0b9fcb3

Please sign in to comment.