Graphical PDS migrator for AT Protocol
1import { PageProps } from "fresh";
2import LoginSelector from "../../islands/LoginSelector.tsx"
3
4export async function submitHandle(handle: string) {
5 const response = await fetch("/api/oauth/initiate", {
6 method: "POST",
7 headers: {
8 "Content-Type": "application/json",
9 },
10 body: JSON.stringify({ handle }),
11 });
12
13 if (!response.ok) {
14 const errorText = await response.text();
15 throw new Error(errorText || "Login failed");
16 }
17
18 const data = await response.json();
19
20 // Add a small delay before redirecting for better UX
21 await new Promise((resolve) => setTimeout(resolve, 500));
22
23 // Redirect to ATProto OAuth flow
24 globalThis.location.href = data.redirectUrl;
25}
26
27export default function Login(_props: PageProps) {
28 return (
29 <>
30 <div className="flex flex-col gap-8">
31 <LoginSelector />
32 </div>
33 </>
34 );
35}