Graphical PDS migrator for AT Protocol

logout after migration

Changed files
+40 -7
islands
routes
api
+19 -2
islands/MigrationProgress.tsx
···
))}
</div>
-
-
{steps[3].status === "completed" && (
<div class="p-4 bg-green-50 dark:bg-green-900 rounded-lg border-2 border-green-200 dark:border-green-800">
<p class="text-sm text-green-800 dark:text-green-200">
Migration completed successfully! You can now close this page.
</p>
+
<button
+
onClick={async () => {
+
try {
+
const response = await fetch("/api/logout", {
+
method: "POST",
+
credentials: "include",
+
});
+
if (!response.ok) {
+
throw new Error("Logout failed");
+
}
+
globalThis.location.href = "/";
+
} catch (error) {
+
console.error("Failed to logout:", error);
+
}
+
}}
+
class="mt-4 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md transition-colors duration-200"
+
>
+
Sign Out
+
</button>
</div>
)}
</div>
+17 -4
islands/MigrationSetup.tsx
···
const [confirmationText, setConfirmationText] = useState("");
const [passport, setPassport] = useState<UserPassport | null>(null);
+
const ensureServiceUrl = (url: string): string => {
+
if (!url) return url;
+
try {
+
// If it already has a protocol, return as is
+
new URL(url);
+
return url;
+
} catch {
+
// If no protocol, add https://
+
return `https://${url}`;
+
}
+
};
+
useEffect(() => {
if (!IS_BROWSER) return;
···
};
const handleServiceChange = (value: string) => {
-
setService(value);
+
const urlWithProtocol = ensureServiceUrl(value);
+
setService(urlWithProtocol);
setError("");
-
if (value) {
-
checkServerDescription(value);
+
if (urlWithProtocol) {
+
checkServerDescription(urlWithProtocol);
} else {
setAvailableDomains([]);
setSelectedDomain("");
···
<div class="text-center mb-4 mt-6">
<h3 class="text-2xl font-bold text-red-600 mb-2 tracking-wide">Final Boarding Call</h3>
<p class="text-gray-700 dark:text-gray-300 mb-2 text-base">
-
<span class="font-semibold text-red-500">Warning:</span> This migration process can be <strong>irreversible</strong>.<br />Airport is in <strong>alpha</strong> currently, and we don't recommend it for main accounts.
+
<span class="font-semibold text-red-500">Warning:</span> This migration process can be <strong>irreversible</strong>.<br />Airport is in <strong>alpha</strong> currently, and we don't recommend it for main accounts. Migrate at your own risk. We reccomend backing up your data before proceeding.
</p>
<p class="text-gray-700 dark:text-gray-300 mb-4 text-base">
Please type <span class="font-mono font-bold text-blue-600">MIGRATE</span> below to confirm and proceed.
+4 -1
routes/api/logout.ts
···
-
import { getSession } from "../../lib/sessions.ts";
+
import { getSession, destroyAllSessions } from "../../lib/sessions.ts";
import { oauthClient } from "../../lib/oauth/client.ts";
import { define } from "../../utils.ts";
···
// Then destroy the iron session
session.destroy();
}
+
+
// Destroy all sessions including migration session
+
await destroyAllSessions(req);
return response;
} catch (error: unknown) {