- web: Gitea OAuth2 login, signed session cookie, everything behind login; inbox with answers, project board (goals → tasks), task page with OpenSpec artifacts, questions and session controls; new project form; auto-refresh, light/dark, mobile - users + projects.owner_id; tokens AES-256-GCM encrypted; owner-only access - provisionProject (runner): new or existing Gitea repo, peppa-bot collaborator, template + openspec init, push, rollback; used by web and peppa project create (replaces scripts/bootstrap-project.sh) - peppa web login-link, peppa project owner; Gitea OAuth app script - bins/template resolved via PEPPA_ROOT (works inside the Next build) - testkit: mock-gitea + 10 tests (42 e2e total, all green) - OpenSpec: pep-1-web-platform archived into specs web-auth, project-provisioning, web-workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
16 lines
765 B
TypeScript
16 lines
765 B
TypeScript
import { consumeLoginLink } from "@peppa/core";
|
|
import { NextResponse, type NextRequest } from "next/server";
|
|
import { publicOrigin, sessionCookie } from "@/lib/auth";
|
|
import { db } from "@/lib/db";
|
|
|
|
/** One-time admin login link from `peppa web login-link`. */
|
|
export async function GET(req: NextRequest) {
|
|
const origin = await publicOrigin();
|
|
const uid = await consumeLoginLink(db, req.nextUrl.searchParams.get("code") ?? "");
|
|
if (!uid) return NextResponse.redirect(`${origin}/login?error=${encodeURIComponent("Ссылка входа недействительна или уже использована")}`);
|
|
const res = NextResponse.redirect(`${origin}/`);
|
|
const c = sessionCookie(uid);
|
|
res.cookies.set(c.name, c.value, c.options);
|
|
return res;
|
|
}
|