41 lines
2.2 KiB
TypeScript
41 lines
2.2 KiB
TypeScript
import { redirect } from "next/navigation";
|
||
import { currentUser, safeNext } from "@/lib/auth";
|
||
import { Brand } from "@/components/Brand";
|
||
import { Flash } from "@/components/common";
|
||
import { EgovSign } from "@/components/EgovSign";
|
||
import { Footer } from "@/components/Footer";
|
||
import { Button } from "@/components/ui/button";
|
||
import { Input } from "@/components/ui/input";
|
||
|
||
export const dynamic = "force-dynamic";
|
||
|
||
export default async function Login({ searchParams }: { searchParams: Promise<{ error?: string; next?: string; login?: string }> }) {
|
||
const { error, next, login } = await searchParams;
|
||
if (await currentUser()) redirect(safeNext(next));
|
||
return (
|
||
<main className="grid min-h-dvh place-items-center px-4">
|
||
<div className="flex w-full max-w-sm flex-col items-center gap-5 text-center">
|
||
<Brand large />
|
||
<p className="m-0 text-sm text-muted-foreground">Софтвейр-фабрика: проекты в Gitea, стори по OpenSpec, агенты Claude Code и Codex.</p>
|
||
<Flash error={error} />
|
||
<Button asChild variant="default" size="lg" className="w-full">
|
||
<a href={`/auth/start?next=${encodeURIComponent(safeNext(next))}`}>Войти через Gitea</a>
|
||
</Button>
|
||
<EgovSign purpose="login" next={safeNext(next)} label="Войти через eGov" />
|
||
<div className="flex w-full items-center gap-3 text-xs text-muted-foreground">
|
||
<span className="h-px flex-1 bg-border" />
|
||
или по логину Пеппы
|
||
<span className="h-px flex-1 bg-border" />
|
||
</div>
|
||
<form action="/auth/password" method="post" className="flex w-full flex-col gap-2" aria-label="Вход по логину и паролю">
|
||
<input type="hidden" name="next" value={safeNext(next)} />
|
||
<Input name="login" placeholder="Логин" aria-label="Логин" autoComplete="username" autoCapitalize="none" spellCheck={false} required defaultValue={login ?? ""} />
|
||
<Input name="password" type="password" placeholder="Пароль" aria-label="Пароль" autoComplete="current-password" required />
|
||
<Button size="lg" className="w-full">Войти</Button>
|
||
</form>
|
||
<Footer />
|
||
</div>
|
||
</main>
|
||
);
|
||
}
|