peppa/apps/web/app/login/page.tsx
Асель 414e4500e4 PEP-68: local users without Gitea — password login, superadmin management
- users.password_hash/password_set_at/disabled_at (migration 0002_local_users)
- core/local-users.ts: scrypt, passwordLogin with attempt limits, create/reset/disable
- isSuperadmin(db, user) = platform.admins; isUserAllowed honours disabled_at
- web: /auth/password + login form, /users for superadmins, Settings → password
- Gitea login with a local user's login is refused (giteaLoginRefusal)
- local users: projects in peppa-bot namespace, members without Gitea collaboration
- CLI: peppa user add|passwd|disable|enable; tests in testkit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 03:20:21 +05:00

41 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>
);
}