diff --git a/app/views/install/installer/js/modules/progress.js b/app/views/install/installer/js/modules/progress.js index a6e784ada9..7f7b23e3fc 100644 --- a/app/views/install/installer/js/modules/progress.js +++ b/app/views/install/installer/js/modules/progress.js @@ -27,6 +27,7 @@ let activeInstall = null; let unloadGuard = null; + let sseSessionDetails = null; const csrfToken = document.querySelector('meta[name="appwrite-installer-csrf"]')?.getAttribute('content') || ''; const withCsrfHeader = (headers = {}) => { @@ -524,6 +525,9 @@ inProgress: payload.message || payload.step, done: payload.message || payload.step }; + if (step.id === STEP_IDS.ACCOUNT_SETUP && payload.details?.sessionSecret) { + sseSessionDetails = payload.details; + } progressState.set(step.id, { status: payload.status || STATUS.IN_PROGRESS, message: payload.message, @@ -599,7 +603,7 @@ }); if (!allDone) return; const accountState = progressState.get(STEP_IDS.ACCOUNT_SETUP); - const sessionDetails = accountState?.details; + const sessionDetails = sseSessionDetails || accountState?.details; finalizeInstall(); notifyInstallComplete(activeInstall?.installId, sessionDetails).finally(() => { setTimeout(() => redirectToApp(), TIMINGS?.redirectDelay ?? 0); @@ -740,7 +744,7 @@ } const accountState = progressState.get(STEP_IDS.ACCOUNT_SETUP); - const sessionDetails = accountState?.details; + const sessionDetails = sseSessionDetails || accountState?.details; finalizeInstall(); notifyInstallComplete(activeInstall?.installId, sessionDetails).finally(() => { setTimeout(() => redirectToApp(), TIMINGS?.redirectDelay ?? 0); diff --git a/src/Appwrite/Platform/Installer/Http/Installer/Complete.php b/src/Appwrite/Platform/Installer/Http/Installer/Complete.php index da8985396f..92a00651fe 100644 --- a/src/Appwrite/Platform/Installer/Http/Installer/Complete.php +++ b/src/Appwrite/Platform/Installer/Http/Installer/Complete.php @@ -48,6 +48,16 @@ class Complete extends Action @touch(Server::INSTALLER_COMPLETE_FILE); + if (!$sessionSecret && $installId !== '') { + $data = $state->readProgressFile($installId); + $details = $data['details'][Server::STEP_ACCOUNT_SETUP] ?? []; + if (!empty($details['sessionSecret'])) { + $sessionSecret = $details['sessionSecret']; + $sessionId = $sessionId ?: ($details['sessionId'] ?? ''); + $sessionExpire = $sessionExpire ?: ($details['sessionExpire'] ?? ''); + } + } + if ($sessionSecret) { $isHttps = $request->getProtocol() === 'https'; $sameSite = $isHttps ? Response::COOKIE_SAMESITE_NONE : Response::COOKIE_SAMESITE_LAX;