Admin app simplification by using API auth properly. Implemented promise to keep request blocked by permission check while the user authenticates, fixing concurrent requests.

This commit is contained in:
Leo Vasanko
2025-12-03 21:19:40 -06:00
parent 7983d9b170
commit b373a84065
2 changed files with 25 additions and 96 deletions
+4 -3
View File
@@ -228,9 +228,10 @@ export async function apiFetch(url, options = {}) {
// If we can't parse JSON, no iframe available
}
// Authenticate via iframe (if not already in a frame, and no existing #auth-iframe)
if (authInfo?.iframe && window === window.top && !isAuthIframeOpen()) {
// Show auth iframe and wait for success (throws AuthCancelledError on cancel)
// Authenticate via iframe (only in top-level window)
if (authInfo?.iframe && window === window.top) {
// Show auth iframe (or wait for existing one) and retry on success
// showAuthIframe returns existing promise if iframe is already open
await showAuthIframe(authInfo.iframe)
continue // Retry the original request
}