From 144842b4dacb51c417f8249145c273e2be208f1a Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 14 Aug 2015 07:08:49 +0000 Subject: [PATCH] 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 --- route.php | 9 +++++++++ 1 file changed, 9 insertions(+) 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));