fix: workaround sibAuth

This commit is contained in:
Jean-Baptiste Pasquier 2021-05-17 12:49:17 +02:00
parent fbedd82642
commit 496c72f1ae
2 changed files with 12 additions and 0 deletions

View File

@ -1,9 +1,13 @@
window.requestLogin = false; window.requestLogin = false;
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
const sibAuth = document.querySelector("sib-auth"); const sibAuth = document.querySelector("sib-auth");
const timeoutNoUser = setTimeout(() => {
sibAuth.login();
}, 15000);
if (sibAuth) { if (sibAuth) {
sibAuth.getUser() sibAuth.getUser()
.then(user => { .then(user => {
clearTimeout(timeoutNoUser);
if (user !== null) { if (user !== null) {
document document
.querySelectorAll(".notLoggedIn") .querySelectorAll(".notLoggedIn")

View File

@ -81,9 +81,13 @@ document.addEventListener("DOMContentLoaded", function () {
// Workaround - No "navigate" event after the login on `/login` // Workaround - No "navigate" event after the login on `/login`
if (window.location.pathname == "/login") { if (window.location.pathname == "/login") {
const sibAuth = document.querySelector("sib-auth"); const sibAuth = document.querySelector("sib-auth");
const timeoutNoUser = setTimeout(() => {
sibAuth.login();
}, 15000);
if (sibAuth) { if (sibAuth) {
sibAuth.getUser() sibAuth.getUser()
.then(user => { .then(user => {
clearTimeout(timeoutNoUser);
if (user !== null) { if (user !== null) {
window.dispatchEvent( window.dispatchEvent(
new CustomEvent('requestNavigation', { new CustomEvent('requestNavigation', {
@ -124,9 +128,13 @@ document.addEventListener("DOMContentLoaded", function () {
closeUserControls(); closeUserControls();
if (e.detail.route.startsWith('login')) { if (e.detail.route.startsWith('login')) {
const sibAuth = document.querySelector("sib-auth"); const sibAuth = document.querySelector("sib-auth");
const timeoutNoUser2 = setTimeout(() => {
sibAuth.login();
}, 15000);
if (sibAuth) { if (sibAuth) {
sibAuth.getUser() sibAuth.getUser()
.then(user => { .then(user => {
clearTimeout(timeoutNoUser2);
if (user !== null) { if (user !== null) {
window.dispatchEvent( window.dispatchEvent(
new CustomEvent('requestNavigation', { new CustomEvent('requestNavigation', {