92 lines
2.3 KiB
JavaScript
92 lines
2.3 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';
|
|
|
|
// re-activate button
|
|
gstore.add('popup_opened', false);
|
|
|
|
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;
|
|
case -5:
|
|
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.<br>(errcode: popup_interrupt)';
|
|
break;
|
|
}
|
|
|
|
// re-activate button
|
|
gstore.add('popup_opened', false);
|
|
|
|
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';
|
|
|
|
var redirect_url = `/${gstore.get.URI.join('/')}`;
|
|
|
|
setTimeout(function(){ document.location = redirect_url; }, 1500);
|
|
|
|
}
|
|
|
|
|
|
} }, 1);
|
|
|
|
};
|