Skip to content

Commit bed22fc

Browse files
committed
Update SetupPages.cs
1 parent a4cb577 commit bed22fc

1 file changed

Lines changed: 18 additions & 24 deletions

File tree

Services/SetupPages.cs

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ function setTenantMode(section, isMulti) {
216216
}
217217
document.getElementById('manual-redirect-uri').textContent = window.location.origin + '/.auth/login/aad/callback';
218218
if (setupState.isEasyAuthConfigured) {
219-
showBanner('Authentication is already configured. Redirecting...');
220-
setTimeout(() => window.location.href = '/', 2000);
219+
showBanner('Authentication is already configured. This page will redirect shortly.');
221220
return;
222221
}
223222
if (!setupState.isRunningInAppService || !setupState.hasManagedIdentity) {
@@ -459,57 +458,52 @@ async function submitManual() {
459458
}
460459
}
461460
function showRestartScreen() {
462-
// Stop background status polling — restart screen has its own polling
461+
// Stop background status polling
463462
clearInterval(statusPollTimer);
464-
// Hide setup sections, show restart polling UI
463+
// Hide setup sections, show restart status
465464
document.getElementById('user-section').classList.add('hidden');
466465
document.getElementById('auto-section').classList.add('hidden');
467466
document.getElementById('manual-section').classList.add('hidden');
468467
document.getElementById('divider-user').classList.add('hidden');
469468
document.getElementById('divider-auth').classList.add('hidden');
470469
document.querySelector('.subtitle').textContent = '';
471-
document.getElementById('page-title').textContent = 'Restarting...';
470+
document.getElementById('page-title').textContent = 'Setup Complete';
472471
473472
const banner = document.getElementById('status-banner');
474473
banner.innerHTML = '<div style="text-align:center;">' +
475474
'<div style="margin-bottom:0.75rem;">Authentication has been configured. The application is restarting to apply changes.</div>' +
476475
'<div id="restart-spinner" style="font-size:1.5rem;margin-bottom:0.5rem;">&#8987;</div>' +
477-
'<div id="restart-status" style="font-size:0.85rem;color:#94a3b8;">Waiting for the application to come back online...</div>' +
476+
'<div id="restart-status" style="font-size:0.85rem;color:#94a3b8;">Waiting for the new container to come online...</div>' +
478477
'</div>';
479478
banner.classList.remove('hidden');
480479
481-
let attempts = 0;
482-
const maxAttempts = 120; // 10 min at 5s intervals
480+
// Poll /api/setup/status — once the new container comes online with EasyAuth
481+
// configured, isEasyAuthConfigured will be true and setup mode will no longer
482+
// be active. At that point redirect to / and let the app take over.
483483
const pollInterval = 5000;
484-
485484
const pollRestart = async () => {
486-
attempts++;
487-
const statusEl = document.getElementById('restart-status');
488485
try {
489-
const res = await fetch('/api/setup/health', { cache: 'no-store' });
486+
const res = await fetch('/api/setup/status', { cache: 'no-store' });
490487
if (res.ok) {
491488
const data = await res.json();
492-
if (data.ready) {
493-
statusEl.textContent = 'Application is ready! Redirecting...';
489+
if (data.isEasyAuthConfigured && !data.isSetupCompleted) {
490+
// New container is online with EasyAuth active — redirect to app
491+
document.getElementById('restart-status').textContent = 'Application is ready!';
494492
document.getElementById('restart-spinner').textContent = '\u2705';
495-
setTimeout(() => window.location.href = '/', 1500);
493+
setTimeout(() => window.location.href = '/', 1000);
496494
return;
497495
}
496+
// Still on the old container (isSetupCompleted=true) — keep waiting
497+
document.getElementById('restart-status').textContent = 'Auth configured, waiting for container restart...';
498498
}
499499
} catch (e) {
500-
// App still restarting — expected
501-
}
502-
if (attempts >= maxAttempts) {
503-
statusEl.textContent = 'The application is taking longer than expected. Try refreshing the page manually.';
504-
document.getElementById('restart-spinner').textContent = '\u26A0\uFE0F';
505-
return;
500+
// Container is cycling — expected during restart
501+
document.getElementById('restart-status').textContent = 'Container restarting...';
506502
}
507-
statusEl.textContent = 'Waiting for the application to come back online... (' + attempts + ')';
508503
setTimeout(pollRestart, pollInterval);
509504
};
510505
511-
// Start polling after a short delay to let the restart begin
512-
setTimeout(pollRestart, 8000);
506+
setTimeout(pollRestart, 5000);
513507
}
514508
</script>
515509
</body>

0 commit comments

Comments
 (0)