diff --git a/src/Auth/Cas.php b/src/Auth/Cas.php index 0a38af1..fecee04 100644 --- a/src/Auth/Cas.php +++ b/src/Auth/Cas.php @@ -103,12 +103,11 @@ class Cas extends Method { * @return string */ private static function get_cas_callback_url() { - return Url :: get_absolute_url( - 'login/cas_callback?next='.( - isset($_REQUEST['next'])? - $_REQUEST['next']: - urlencode(Url :: get_current_url()) - ) + return Url :: add_url_parameter( + Url :: get_absolute_url('login/cas_callback'), + 'next', + isset($_REQUEST['next'])?$_REQUEST['next']:urlencode(Url :: get_current_url(true)), + false ); } diff --git a/src/Url.php b/src/Url.php index 43e3a33..6f8e9a8 100644 --- a/src/Url.php +++ b/src/Url.php @@ -332,9 +332,11 @@ class Url { /** * Retreive current requested URL and return it * + * @param bool $with_parameters Set to true to retreive current URL with GET parameters + * * @return string|false The current request URL or false if fail **/ - public static function get_current_url() { + public static function get_current_url($with_parameters=false) { Log :: trace("URL : request URI = '".$_SERVER['REQUEST_URI']."'"); $base = self :: get_rewrite_base(); @@ -351,16 +353,13 @@ class Url { $current_url = substr($_SERVER['REQUEST_URI'], strlen($base)); - // URL contain params ? - $params_start = strpos($current_url, '?'); - if ($params_start !== false) - // Params detected, remove it - - // No url / currrent url start by '?' ? - if ($params_start == 0) - return ''; - else - return substr($current_url, 0, $params_start); + if (!$with_parameters) { + // URL contain params ? + $params_start = strpos($current_url, '?'); + if ($params_start !== false) + // Params detected, remove it + $current_url = substr($current_url, 0, $params_start); + } return $current_url; }