diff --git a/lib/rspace-header.ts b/lib/rspace-header.ts index 9f57ed7..15de15b 100644 --- a/lib/rspace-header.ts +++ b/lib/rspace-header.ts @@ -433,6 +433,7 @@ interface AuthModalCallbacks { } let activeModal: HTMLElement | null = null; +let headerRenderFn: (() => void) | null = null; /** * Show the EncryptID auth modal for sign-in or registration. @@ -761,6 +762,9 @@ export function mountHeader(options: HeaderOptions): void { }); } + // Store render function so requireAuth can update the header after auth + headerRenderFn = renderHeader; + // Mount to DOM document.body.prepend(header); renderHeader(); @@ -775,6 +779,11 @@ export function requireAuth(onAuthenticated: () => void): boolean { if (isAuthenticated()) { return true; } - showAuthModal({ onSuccess: onAuthenticated }); + showAuthModal({ + onSuccess: () => { + headerRenderFn?.(); + onAuthenticated(); + }, + }); return false; }