From 81db5a02c82947b273065f8a141080e894e11cd8 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 21 Mar 2018 00:41:44 +0100 Subject: [PATCH] [module.cas] GET works with URL0=0 with redirection | URL0=1 with pop-up management --- build/api/module/casController.php | 31 +++++++++++++++++++++++------- config/modules.json | 2 +- webpack/data/login.js | 2 +- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/build/api/module/casController.php b/build/api/module/casController.php index 5667490..f000187 100644 --- a/build/api/module/casController.php +++ b/build/api/module/casController.php @@ -20,14 +20,15 @@ class casController{ /* (1) Authentication callback * - * GET arguments - * - * @ticket CAS callback @ticket + * @popup_mode Whether to manage the popup + * @GET[ticket] CAS callback @ticket * * @return headers|body The download content * ---------------------------------------------------------*/ public static function get($args){ + $popup_mode = false; + extract($args); // login: https://sso.univ-pau.fr/cas/login?service=http://ptut.com:8080/api/v/1.0/cas @@ -54,10 +55,26 @@ class casController{ ---------------------------------------------------------*/ /* (1) Global DOWNLOAD data */ $headers = ['Content-Type' => 'text/html; charset=UTF-8' ]; - $body_start = "Veuillez patienter...
Vous allez être redirigés"; - /* (2) Reset SESSION */ + /* (2) If @popup_mode */ + if( $popup_mode !== 0 ){ + + $body_start = "Veuillez patienter...
Vous allez être redirigés"; + + /* (3) Else -> redirection */ + + }else{ + + $homepage = ($_SERVER['SERVER_NAME'] == 'ptut.com' ) ? 'http' : 'https'; + $homepage .= '://'.$_SERVER['HTTP_HOST'].'/home'; + + $body_start = "Veuillez patienter...
Vous allez être redirigés"; + + } + + /* (4) Reset SESSION */ $_SESSION['CAS'] = []; @@ -84,7 +101,7 @@ class casController{ ---------------------------------------------------------*/ /* (1) Build useful variables */ $service = ($_SERVER['SERVER_NAME'] == 'ptut.com' ) ? 'http' : 'https'; - $service .= '://'.$_SERVER['HTTP_HOST'].'/api/v/1.0/cas'; + $service .= '://'.$_SERVER['HTTP_HOST'].'/api/v/1.0/cas/'.$popup_mode; $ticket = urlencode($_GET['ticket']); $validate_url = "https://sso.univ-pau.fr/cas/serviceValidate?ticket=$ticket&service=$service"; diff --git a/config/modules.json b/config/modules.json index af5b438..1731f1a 100644 --- a/config/modules.json +++ b/config/modules.json @@ -27,7 +27,7 @@ "des": "Authenticatation callback (used by third-party OAuth)", "per": [], "par": { - "URL0": { "des": "Whether to manage a popup", "typ": "boolean", "opt": true, "ren": "popup_mode", "def": false } + "URL0": { "des": "Whether to manage a popup", "typ": "id", "opt": true, "ren": "popup_mode", "def": 0 } }, "opt": { "download": true } }, diff --git a/webpack/data/login.js b/webpack/data/login.js index 511a3fa..ff5f02f 100644 --- a/webpack/data/login.js +++ b/webpack/data/login.js @@ -10,7 +10,7 @@ gstore.add('popup_click', function(){ gstore.get.popup_opened = true; /* (3) Open popup */ - window.pop = window.open('https://sso.univ-pau.fr/cas/login?service='+window.api.target+'cas', '_blank', 'location=no,height=1024,width=1024,scrollbars=yes,status=no'); + window.pop = window.open('https://sso.univ-pau.fr/cas/login?service='+window.api.target+'cas/1', '_blank', 'location=no,height=1024,width=1024,scrollbars=yes,status=no'); /* (4) Clear interval (optional) */ !isNaN(window.popint) && clearInterval(window.popint);