Skip to content

Commit

Permalink
Use a class constant for easier extandability.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark S committed Sep 14, 2016
1 parent ffa464d commit 59fec3d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Controller/Component/AuthComponent.php
Expand Up @@ -39,6 +39,12 @@ class AuthComponent extends Component

use EventDispatcherTrait;

/**
* The query string key used for remembering the referrered page when getting
* redirected to login.
*/
const QUERY_STRING_REDIRECT = 'redirect';

/**
* Constant for 'all'
*
Expand Down Expand Up @@ -394,9 +400,9 @@ protected function _loginActionRedirectUrl()

$loginAction = $this->_config['loginAction'];
if (is_array($loginAction)) {
$loginAction['?']['redirect'] = $currentUrl;
$loginAction['?'][static::QUERY_STRING_REDIRECT] = $currentUrl;
} else {
$loginAction .= '?redirect=' . rawurlencode($currentUrl);
$loginAction .= '?' . static::QUERY_STRING_REDIRECT . '=' . rawurlencode($currentUrl);
}

return $loginAction;
Expand Down Expand Up @@ -754,7 +760,7 @@ protected function _getUser()
*/
public function redirectUrl($url = null)
{
$redirectUrl = $this->request->query('redirect');
$redirectUrl = $this->request->query(self::QUERY_STRING_REDIRECT);
if ($redirectUrl && (substr($redirectUrl, 0, 1) !== '/')) {
$redirectUrl = null;
}
Expand Down

0 comments on commit 59fec3d

Please sign in to comment.