2018-02-19 23:53:08 +00:00
|
|
|
/* (1) Imports
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) NPM libs */
|
|
|
|
import Vue from 'vue'
|
|
|
|
|
2018-02-20 21:57:52 +00:00
|
|
|
/* (2) Vues */
|
2018-02-27 13:33:04 +00:00
|
|
|
import login_wrapper_vue from '../vue/login_wrapper.vue'
|
2018-02-19 23:53:08 +00:00
|
|
|
|
2018-02-20 21:57:52 +00:00
|
|
|
/* (3) Data */
|
|
|
|
require('../data/common');
|
2018-03-03 15:00:43 +00:00
|
|
|
require('../data/login');
|
2018-02-19 23:53:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-20 21:57:52 +00:00
|
|
|
/* (2) Initialisation
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) Render view */
|
2018-02-19 23:53:08 +00:00
|
|
|
new Vue({
|
|
|
|
el: '#main-vue',
|
2018-02-27 13:33:04 +00:00
|
|
|
render: h => h(login_wrapper_vue)
|
|
|
|
});
|
|
|
|
|
2018-03-03 15:00:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* (1) Initialize CAS pop-up mechanism */
|
|
|
|
window.pop = { closed: false };
|
|
|
|
|
|
|
|
window.cas_callback = function(cas_login){
|
|
|
|
|
2018-03-03 15:21:41 +00:00
|
|
|
/* (1) Wait 1ms for popup to really be closed */
|
|
|
|
setTimeout( function(){ if( window.pop.closed ){
|
2018-03-03 15:00:43 +00:00
|
|
|
|
2018-03-03 15:21:41 +00:00
|
|
|
/* (2) Stop interval that checks if window closed */
|
2018-03-19 17:27:33 +00:00
|
|
|
!isNaN(window.popint) && clearInterval(window.popint);
|
2018-03-03 15:00:43 +00:00
|
|
|
|
2018-03-03 15:21:41 +00:00
|
|
|
/* (3) If no login -> error */
|
|
|
|
if( cas_login === null ){
|
2018-03-19 17:27:33 +00:00
|
|
|
|
2018-03-03 15:21:41 +00:00
|
|
|
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.';
|
|
|
|
gstore.get.login_class = 'invalid';
|
2018-03-03 15:00:43 +00:00
|
|
|
|
2018-03-20 09:25:30 +00:00
|
|
|
// re-activate button
|
|
|
|
gstore.add('popup_opened', false);
|
|
|
|
|
2018-03-31 11:11:59 +00:00
|
|
|
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 3000);
|
2018-03-03 15:00:43 +00:00
|
|
|
|
2018-03-20 09:19:32 +00:00
|
|
|
/* (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;
|
2018-03-20 10:49:26 +00:00
|
|
|
case -5:
|
|
|
|
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.<br>(errcode: popup_interrupt)';
|
|
|
|
break;
|
2018-03-20 09:19:32 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 09:25:30 +00:00
|
|
|
// re-activate button
|
|
|
|
gstore.add('popup_opened', false);
|
|
|
|
|
2018-03-31 11:11:59 +00:00
|
|
|
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 3000);
|
2018-03-20 09:19:32 +00:00
|
|
|
|
2018-03-03 15:21:41 +00:00
|
|
|
/* (4) If login -> reload page */
|
2018-03-20 09:22:55 +00:00
|
|
|
}else{
|
2018-03-03 15:21:41 +00:00
|
|
|
|
|
|
|
gstore.get.login_error_text = 'Vous êtes connectés. Vous allez être redirigé.';
|
|
|
|
gstore.get.login_class = 'valid';
|
2018-03-19 17:27:33 +00:00
|
|
|
|
2018-03-20 11:09:26 +00:00
|
|
|
var redirect_url = `/${gstore.get.URI.join('/')}`;
|
|
|
|
|
2018-03-31 11:11:59 +00:00
|
|
|
setTimeout(function(){ document.location = redirect_url; }, 3000);
|
2018-03-03 15:21:41 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} }, 1);
|
2018-03-03 15:00:43 +00:00
|
|
|
|
|
|
|
};
|