From 496c72f1aeea002656f7dfa2bc9e564d6b212b2b Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Pasquier Date: Mon, 17 May 2021 12:49:17 +0200 Subject: [PATCH] fix: workaround sibAuth --- src/scripts/login-element-visibility.js | 4 ++++ src/scripts/navigate-event.js | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/scripts/login-element-visibility.js b/src/scripts/login-element-visibility.js index 2367b0b..6337812 100644 --- a/src/scripts/login-element-visibility.js +++ b/src/scripts/login-element-visibility.js @@ -1,9 +1,13 @@ window.requestLogin = false; document.addEventListener("DOMContentLoaded", function () { const sibAuth = document.querySelector("sib-auth"); + const timeoutNoUser = setTimeout(() => { + sibAuth.login(); + }, 15000); if (sibAuth) { sibAuth.getUser() .then(user => { + clearTimeout(timeoutNoUser); if (user !== null) { document .querySelectorAll(".notLoggedIn") diff --git a/src/scripts/navigate-event.js b/src/scripts/navigate-event.js index 0ac62eb..7d358b0 100644 --- a/src/scripts/navigate-event.js +++ b/src/scripts/navigate-event.js @@ -81,9 +81,13 @@ document.addEventListener("DOMContentLoaded", function () { // Workaround - No "navigate" event after the login on `/login` if (window.location.pathname == "/login") { const sibAuth = document.querySelector("sib-auth"); + const timeoutNoUser = setTimeout(() => { + sibAuth.login(); + }, 15000); if (sibAuth) { sibAuth.getUser() .then(user => { + clearTimeout(timeoutNoUser); if (user !== null) { window.dispatchEvent( new CustomEvent('requestNavigation', { @@ -124,9 +128,13 @@ document.addEventListener("DOMContentLoaded", function () { closeUserControls(); if (e.detail.route.startsWith('login')) { const sibAuth = document.querySelector("sib-auth"); + const timeoutNoUser2 = setTimeout(() => { + sibAuth.login(); + }, 15000); if (sibAuth) { sibAuth.getUser() .then(user => { + clearTimeout(timeoutNoUser2); if (user !== null) { window.dispatchEvent( new CustomEvent('requestNavigation', {