route : allow the 401 error code to be redirected to an external URL to authenticate the user

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2237 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-08-14 07:08:49 +00:00
parent 0dff869ccd
commit 144842b4da

View File

@@ -28,6 +28,9 @@ class route
public $errors = null;
/** Preroute used in modules */
public $preroute = "";
/** Authentication URL used if a 401 error is raised. If none is defined,
just display a "Unauthorized" message */
public $authenticationURL = null;
/** Return the baseURL of the site
Always finish with a slash
@@ -456,6 +459,12 @@ class route
exit;
}
if ($this->authenticationURL !== null && $getCode === 401)
{
// Non autorized users should be authenticated
$this->redirect ($this->authenticationURL.$this->requestURL(), "");
}
$http = new http ();
@header ($_SERVER["SERVER_PROTOCOL"]." $getCode ".
$http->codetext ($getCode));