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;
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")

View File

@ -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', {