[module.cas] dispatch custom error codes [webpack.login] display error codes
This commit is contained in:
parent
14c71d88f1
commit
e67195871f
|
@ -71,7 +71,7 @@ class casController{
|
||||||
|
|
||||||
/* (2) Fail if no ticket */
|
/* (2) Fail if no ticket */
|
||||||
if( !isset($_GET['ticket']) || !is_string($_GET['ticket']) || strlen($_GET['ticket']) < 1 )
|
if( !isset($_GET['ticket']) || !is_string($_GET['ticket']) || strlen($_GET['ticket']) < 1 )
|
||||||
return [ 'headers' => $headers, 'body' => $body_start.'null'.$body_end ];
|
return [ 'headers' => $headers, 'body' => $body_start.'-1'.$body_end ];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,14 +95,14 @@ class casController{
|
||||||
|
|
||||||
/* (4) Fail if not validated */
|
/* (4) Fail if not validated */
|
||||||
if( strpos($output, 'user') === false )
|
if( strpos($output, 'user') === false )
|
||||||
return [ 'headers' => $headers, 'body' => $body_start.'null'.$body_end ];
|
return [ 'headers' => $headers, 'body' => $body_start.'-2'.$body_end ];
|
||||||
|
|
||||||
/* (5) Extract cas_login */
|
/* (5) Extract cas_login */
|
||||||
$cas_login = trim(strip_tags($output));
|
$cas_login = trim(strip_tags($output));
|
||||||
|
|
||||||
/* (6) Check empty */
|
/* (6) Check empty */
|
||||||
if( strlen($cas_login) < 1 )
|
if( strlen($cas_login) < 1 )
|
||||||
return [ 'headers' => $headers, 'body' => $body_start.'null'.$body_end ];
|
return [ 'headers' => $headers, 'body' => $body_start.'-2'.$body_end ];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class casController{
|
||||||
|
|
||||||
/* (2) Failure: if no department for @cas_login */
|
/* (2) Failure: if no department for @cas_login */
|
||||||
if( count($departments) === 0 )
|
if( count($departments) === 0 )
|
||||||
return [ 'headers' => $headers, 'body' => $body_start.'null'.$body_end ];
|
return [ 'headers' => $headers, 'body' => $body_start.'-3'.$body_end ];
|
||||||
|
|
||||||
/* (3) Set departments data */
|
/* (3) Set departments data */
|
||||||
$_SESSION['AvailableDepartment'] = $departments;
|
$_SESSION['AvailableDepartment'] = $departments;
|
||||||
|
@ -137,7 +137,7 @@ class casController{
|
||||||
|
|
||||||
/* (2) If not found -> reset SESSION */
|
/* (2) If not found -> reset SESSION */
|
||||||
if( !is_array($by_login) || !isset($by_login['idProfesseur']) || !isset($by_login['admin']) )
|
if( !is_array($by_login) || !isset($by_login['idProfesseur']) || !isset($by_login['admin']) )
|
||||||
return [ 'headers' => $headers, 'body' => $body_start.'null'.$body_end ];
|
return [ 'headers' => $headers, 'body' => $body_start.'-4'.$body_end ];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,31 @@ window.cas_callback = function(cas_login){
|
||||||
|
|
||||||
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 1500);
|
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 1500);
|
||||||
|
|
||||||
|
/* (4) If error code -> display error */
|
||||||
|
}else if( !isNaN(cas_login) ){
|
||||||
|
|
||||||
|
gstore.get.login_class = 'invalid';
|
||||||
|
|
||||||
|
switch(cas_login){
|
||||||
|
case -1:
|
||||||
|
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.<br>(errcode: no_ticket_received)';
|
||||||
|
break;
|
||||||
|
case -2:
|
||||||
|
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.<br>(errcode: cas_not_authed)';
|
||||||
|
break;
|
||||||
|
case -3:
|
||||||
|
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.<br>(errcode: no_meta_department)';
|
||||||
|
break;
|
||||||
|
case -4:
|
||||||
|
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.<br>(errcode: no_matching_professor)';
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 1500);
|
||||||
|
|
||||||
/* (4) If login -> reload page */
|
/* (4) If login -> reload page */
|
||||||
}else{
|
}else{{
|
||||||
|
|
||||||
gstore.get.login_error_text = 'Vous êtes connectés. Vous allez être redirigé.';
|
gstore.get.login_error_text = 'Vous êtes connectés. Vous allez être redirigé.';
|
||||||
gstore.get.login_class = 'valid';
|
gstore.get.login_class = 'valid';
|
||||||
|
|
Loading…
Reference in New Issue