Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ› Fixes flash of empty dashboard during re-auth flow

Alicia Sykesac6f4d4ad22a
diff --git a/src/main.js b/src/main.js
index 81fd90f7..a2f4997a 100644
--- a/src/main.js
+++ b/src/main.js
@@ -67,7 +67,8 @@ const handleAuthFailure = (provider, err) => {
router.isReady().then(() => {
if (isOidcEnabled()) {
- initOidcAuth().then(mount).catch((e) => handleAuthFailure('OIDC', e));
+ initOidcAuth().then((reloading) => { if (!reloading) mount(); })
+ .catch((e) => handleAuthFailure('OIDC', e));
} else if (isKeycloakEnabled()) {
initKeycloakAuth().then(mount).catch((e) => handleAuthFailure('Keycloak', e));
} else if (isHeaderAuthEnabled()) {
diff --git a/src/utils/auth/OidcAuth.js b/src/utils/auth/OidcAuth.js
index 7a96554a..395d3dcd 100644
--- a/src/utils/auth/OidcAuth.js
+++ b/src/utils/auth/OidcAuth.js
@@ -78,6 +78,8 @@ class OidcAuth {
});
}
+ /* Returns true when a same-page reload is scheduled, signalling the caller
+ * to skip mounting the throwaway frame the reload would immediately discard. */
async login() {
const hadValidToken = Boolean(getApiAuthHeader());
const url = new URL(window.location.href);
@@ -104,7 +106,7 @@ class OidcAuth {
const returnTo = safeReturnTo(callbackUser.state);
toast(i18n.global.t('login.authenticated-redirecting'), { type: 'success' });
setTimeout(() => window.location.replace(returnTo), 600);
- return;
+ return true;
}
const user = await this.userManager.getUser();
@@ -127,7 +129,9 @@ class OidcAuth {
if (!hadValidToken && getApiAuthHeader()) {
toast(i18n.global.t('login.authenticated-redirecting'), { type: 'success' });
setTimeout(() => window.location.reload(), 500);
+ return true;
}
+ return false;
}
/* Redirect to the IdP for interactive sign-in