[module.cas] dispatch custom error codes [webpack.login] display error codes

This commit is contained in:
xdrm-brackets 2018-03-20 10:19:32 +01:00
parent 14c71d88f1
commit e67195871f
2 changed files with 33 additions and 10 deletions

View File

@ -71,7 +71,7 @@ class casController{
/* (2) Fail if no ticket */
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 */
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 */
$cas_login = trim(strip_tags($output));
/* (6) Check empty */
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 */
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 */
$_SESSION['AvailableDepartment'] = $departments;
@ -137,7 +137,7 @@ class casController{
/* (2) If not found -> reset SESSION */
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 ];

View File

@ -42,8 +42,31 @@ window.cas_callback = function(cas_login){
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 */
}else{
}else{{
gstore.get.login_error_text = 'Vous êtes connectés. Vous allez être redirigé.';
gstore.get.login_class = 'valid';