diff --git a/build/api/module/casController.php b/build/api/module/casController.php
index 9b1b281..2667d27 100644
--- a/build/api/module/casController.php
+++ b/build/api/module/casController.php
@@ -48,7 +48,7 @@ class casController{
/* (0) Global DOWNLOAD data
---------------------------------------------------------*/
$headers = ['Content-Type' => 'text/html; charset=UTF-8' ];
- $body_start = "Veuillez patienter...
Vous allez être redirigés";
diff --git a/webpack/data/login.js b/webpack/data/login.js
index 358a83c..3311bf9 100644
--- a/webpack/data/login.js
+++ b/webpack/data/login.js
@@ -1,11 +1,25 @@
+gstore.add('popup_opened', false);
+
gstore.add('popup_click', function(){
- /* (1) Open popup */
+ /* (1) Do nothing if already opened */
+ if( gstore.get.popup_opened )
+ return;
+
+ /* (2) Store that popup is opened */
+ gstore.get.popup_opened = true;
+
+ /* (3) Open popup */
window.pop = window.open('https://sso.univ-pau.fr/cas/login?service='+window.api.target+'cas', '_blank', 'location=no,height=1024,width=1024,scrollbars=yes,status=no');
- /* (2) If popup closed -> abort */
+ /* (4) Clear interval (optional) */
+ !isNaN(window.popint) && clearInterval(window.popint);
+
+ /* (5) Check if popup closed -> abort */
window.popint = setInterval(function(){ window.pop.closed && window.cas_callback(null); }, 500);
+
+
});
gstore.add('login_class', 'neutral');
diff --git a/webpack/page/login.js b/webpack/page/login.js
index c7833de..9327d76 100644
--- a/webpack/page/login.js
+++ b/webpack/page/login.js
@@ -32,11 +32,11 @@ window.cas_callback = function(cas_login){
setTimeout( function(){ if( window.pop.closed ){
/* (2) Stop interval that checks if window closed */
- clearInterval(window.popint);
-
+ !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';
@@ -47,6 +47,7 @@ window.cas_callback = function(cas_login){
gstore.get.login_error_text = 'Vous êtes connectés. Vous allez être redirigé.';
gstore.get.login_class = 'valid';
+
setTimeout(function(){ document.location = '/'; }, 1500);
}