Login: drop AuthProvider dependency so /login exports statically

This commit is contained in:
glass beadian 2026-10-13 13:18:23 +00:00
parent 22f9e12141
commit 8cc1c3b634

View file

@ -4,14 +4,14 @@ import { useState, type FormEvent } from "react";
import Link from "next/link"; import Link from "next/link";
import { Button, Card, Input } from "../../components/ui/primitives"; import { Button, Card, Input } from "../../components/ui/primitives";
import { api, errorMessage } from "../../lib/api-client"; import { api, errorMessage } from "../../lib/api-client";
import { useAuth } from "../../lib/auth-store"; import { setSessionToken } from "../../lib/session-token";
import type { AuthResult } from "../../lib/api-types";
/** /**
* /login — bare sign-in: username and password, nothing else. Account creation * /login — bare sign-in: username and password, nothing else. Account creation
* lives at /signup; collective joining happens with an invite link. * lives at /signup; collective joining happens with an invite link.
*/ */
export default function LoginPage(): React.ReactElement { export default function LoginPage(): React.ReactElement {
const { login } = useAuth();
const [username, setUsername] = useState(""); const [username, setUsername] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
@ -22,7 +22,12 @@ export default function LoginPage(): React.ReactElement {
setBusy(true); setBusy(true);
setError(null); setError(null);
try { try {
await api.post<unknown>("/auth/login", { username: username.trim(), password }, { redirectOn401: false }); const result = await api.post<AuthResult>(
"/auth/login",
{ username: username.trim(), password },
{ redirectOn401: false },
);
setSessionToken(result.token);
window.location.assign("/streams"); window.location.assign("/streams");
} catch (err) { } catch (err) {
setError(errorMessage(err)); setError(errorMessage(err));