Login: drop AuthProvider dependency so /login exports statically
This commit is contained in:
parent
22f9e12141
commit
8cc1c3b634
1 changed files with 8 additions and 3 deletions
|
|
@ -4,14 +4,14 @@ import { useState, type FormEvent } from "react";
|
|||
import Link from "next/link";
|
||||
import { Button, Card, Input } from "../../components/ui/primitives";
|
||||
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
|
||||
* lives at /signup; collective joining happens with an invite link.
|
||||
*/
|
||||
export default function LoginPage(): React.ReactElement {
|
||||
const { login } = useAuth();
|
||||
const [username, setUsername] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
|
@ -22,7 +22,12 @@ export default function LoginPage(): React.ReactElement {
|
|||
setBusy(true);
|
||||
setError(null);
|
||||
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");
|
||||
} catch (err) {
|
||||
setError(errorMessage(err));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue