Exosphere is a set of small, modular, self-hostable community tools built on the AT Protocol. app.exosphere.site
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: better signin err handling

Hugo 0d702384 e639a085

+25 -4
+4
packages/app/src/app.tsx
··· 380 380 } 381 381 382 382 export function App({ moduleRoutes = defaultRoutes }: { moduleRoutes?: ModuleRoute[] }) { 383 + const sphere = sphereState.value.data?.sphere; 384 + useEffect(() => { 385 + document.title = sphere?.name ? `Exosphere | ${sphere.name}` : "Exosphere"; 386 + }, [sphere?.name]); 383 387 return ( 384 388 <LocationProvider> 385 389 <div class={ui.themeRoot}>
+18 -2
packages/app/src/pages/sign-in.tsx
··· 1 1 import { useSignal } from "@preact/signals"; 2 2 import * as ui from "@exosphere/client/ui.css"; 3 3 4 + const ERROR_MESSAGES: Record<string, string> = { 5 + missing_handle: "Please enter your handle.", 6 + login_failed: "We couldn't sign you in with that handle. Please check it and try again.", 7 + }; 8 + 9 + function readInitialState() { 10 + if (typeof window === "undefined") return { handle: "", error: "" }; 11 + const params = new URLSearchParams(window.location.search); 12 + const errorKey = params.get("error") ?? ""; 13 + return { 14 + handle: params.get("handle") ?? "", 15 + error: errorKey ? (ERROR_MESSAGES[errorKey] ?? "Sign in failed.") : "", 16 + }; 17 + } 18 + 4 19 export function SignIn() { 5 - const handle = useSignal(""); 6 - const error = useSignal(""); 20 + const initial = readInitialState(); 21 + const handle = useSignal(initial.handle); 22 + const error = useSignal(initial.error); 7 23 const loading = useSignal(false); 8 24 9 25 const submit = (e: Event) => {
+3 -2
packages/core/src/auth/routes.ts
··· 21 21 auth.get("/login", async (c) => { 22 22 const handle = c.req.query("handle"); 23 23 if (!handle) { 24 - return c.json({ error: "Missing 'handle' query parameter" }, 400); 24 + return c.redirect("/sign-in?error=missing_handle"); 25 25 } 26 26 27 27 try { ··· 32 32 return c.redirect(redirectUrl); 33 33 } catch (err) { 34 34 console.error("[oauth/login] error:", err instanceof Error ? err.message : err); 35 - return c.json({ error: "OAuth login failed" }, 500); 35 + const params = new URLSearchParams({ error: "login_failed", handle }); 36 + return c.redirect(`/sign-in?${params.toString()}`); 36 37 } 37 38 }); 38 39