Skip to content
Permalink
Browse files

Use a class constant for easier extandability.

  • Loading branch information...
dereuromark committed Sep 14, 2016
1 parent ffa464d commit 59fec3dfc6459dca28bc11d2543e23924186202b
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/Controller/Component/AuthComponent.php
@@ -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'
*
@@ -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;
@@ -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;
}

0 comments on commit 59fec3d

Please sign in to comment.
You can’t perform that action at this time.