From c0d85cd078b502375173f45d02ac8f0065ba620d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr>
Date: Thu, 23 May 2024 17:34:28 +0200
Subject: [PATCH] Redirect to login page if feature not available without
 active session

---
 src/router/index.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/router/index.js b/src/router/index.js
index 07367355..8a2ed59c 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -139,7 +139,15 @@ const routes = [
         } else if (offset === "No Content") {
           store.commit('CLEAR_MESSAGES'); // Remove other messages to avoid displaying twice that the user is not connected
           store.commit('DISPLAY_MESSAGE', { comment: `Vous n'avez pas accès à ce signalement ${store.state.user ? 'avec cet utilisateur' : 'hors connexion, veuillez-vous connecter au préalable'}`, level: 'negative' });
-          next({ path: '/' });
+          console.log('store', store);
+          console.log('store.state.configuration.VUE_APP_LOGIN_URL', store.state.configuration.VUE_APP_LOGIN_URL);
+          if (store.state.configuration.VUE_APP_LOGIN_URL) {
+            setTimeout(() => { // delay to allow the message to be read by user
+              window.open(store.state.configuration.VUE_APP_LOGIN_URL)
+            }, 1500);
+          } else {
+            next({ name: 'login' });
+          }
         } else {
           store.commit('DISPLAY_MESSAGE', { comment: 'Désolé, une erreur est survenue pendant la recherche du signalement', level: 'negative' });
           next({ path: '/' });
-- 
GitLab