[module.cas] GET works with URL0=0 with redirection | URL0=1 with pop-up management
This commit is contained in:
parent
46ba44d042
commit
81db5a02c8
|
@ -20,14 +20,15 @@ class casController{
|
|||
|
||||
/* (1) Authentication callback
|
||||
*
|
||||
* GET arguments
|
||||
*
|
||||
* @ticket<String> CAS callback @ticket
|
||||
* @popup_mode<boolean> Whether to manage the popup
|
||||
* @GET[ticket]<String> CAS callback @ticket
|
||||
*
|
||||
* @return headers|body<array> 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...<br>Vous allez être redirigés<script type='text/javascript'>( typeof window.opener.cas_callback === 'function' ) && window.opener.cas_callback(";
|
||||
$body_end = ");window.close();</script>";
|
||||
|
||||
/* (2) Reset SESSION */
|
||||
/* (2) If @popup_mode */
|
||||
if( $popup_mode !== 0 ){
|
||||
|
||||
$body_start = "Veuillez patienter...<br>Vous allez être redirigés<script type='text/javascript'>( typeof window.opener.cas_callback === 'function' ) && window.opener.cas_callback(";
|
||||
$body_end = "); window.close();</script>";
|
||||
|
||||
/* (3) Else -> redirection */
|
||||
|
||||
}else{
|
||||
|
||||
$homepage = ($_SERVER['SERVER_NAME'] == 'ptut.com' ) ? 'http' : 'https';
|
||||
$homepage .= '://'.$_SERVER['HTTP_HOST'].'/home';
|
||||
|
||||
$body_start = "Veuillez patienter...<br>Vous allez être redirigés<script type='text/javascript'>console.log(";
|
||||
$body_end = "); document.location = '$homepage'; </script>";
|
||||
|
||||
}
|
||||
|
||||
/* (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";
|
||||
|
||||
|
|
|
@ -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 }
|
||||
},
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue