81 lines
2.0 KiB
JavaScript
81 lines
2.0 KiB
JavaScript
/* (1) Imports
|
|
---------------------------------------------------------*/
|
|
/* (1) NPM libs */
|
|
import Vue from 'vue'
|
|
|
|
/* (2) Vues */
|
|
import login_wrapper_vue from '../vue/login_wrapper.vue'
|
|
|
|
/* (3) Data */
|
|
require('../data/common');
|
|
require('../data/login');
|
|
|
|
|
|
|
|
|
|
/* (2) Initialisation
|
|
---------------------------------------------------------*/
|
|
/* (1) Render view */
|
|
new Vue({
|
|
el: '#main-vue',
|
|
render: h => h(login_wrapper_vue)
|
|
});
|
|
|
|
|
|
|
|
/* (1) Initialize CAS pop-up mechanism */
|
|
window.pop = { closed: false };
|
|
|
|
window.cas_callback = function(cas_login){
|
|
|
|
/* (1) Wait 1ms for popup to really be closed */
|
|
setTimeout( function(){ if( window.pop.closed ){
|
|
|
|
/* (2) Stop interval that checks if window closed */
|
|
!isNaN(window.popint) && clearInterval(window.popint);
|
|
|
|
/* (3) If no login -> error */
|
|
if( cas_login === null ){
|
|
|
|
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.';
|
|
gstore.get.login_class = 'invalid';
|
|
|
|
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{
|
|
|
|
gstore.get.login_error_text = 'Vous êtes connectés. Vous allez être redirigé.';
|
|
gstore.get.login_class = 'valid';
|
|
|
|
setTimeout(function(){ document.location = '/'; }, 1500);
|
|
|
|
}
|
|
|
|
|
|
} }, 1);
|
|
|
|
};
|