diff --git a/route.php b/route.php index 7bd9e5a..e7f4d74 100644 --- a/route.php +++ b/route.php @@ -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));