de28478a42
- API token model (SHA-256 hashed, debounced lastUsedAt) with Bearer auth - Dual auth middleware (session + API token) in src/lib/api-auth.ts - 23 REST endpoints under /api/v1/ covering all functionality: tokens, proxy-hosts, l4-proxy-hosts, certificates, ca-certificates, client-certificates, access-lists, settings, instances, users, audit-log, caddy/apply - OpenAPI 3.1 spec at /api/v1/openapi.json with fully typed schemas - Swagger UI docs page at /api-docs in the dashboard - API token management integrated into the Profile page - Fix: next build now works under Node.js (bun:sqlite aliased to better-sqlite3) - 89 new API route unit tests + 11 integration tests (592 total) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
800 B
TypeScript
30 lines
800 B
TypeScript
import { requireUser } from "@/src/lib/auth";
|
|
import { getUserById } from "@/src/lib/models/user";
|
|
import { getEnabledOAuthProviders } from "@/src/lib/config";
|
|
import { listApiTokens } from "@/src/lib/models/api-tokens";
|
|
import ProfileClient from "./ProfileClient";
|
|
import { redirect } from "next/navigation";
|
|
|
|
export default async function ProfilePage() {
|
|
const session = await requireUser();
|
|
const userId = Number(session.user.id);
|
|
|
|
const user = await getUserById(userId);
|
|
if (!user) {
|
|
redirect("/login");
|
|
}
|
|
|
|
const [enabledProviders, apiTokens] = await Promise.all([
|
|
Promise.resolve(getEnabledOAuthProviders()),
|
|
listApiTokens(userId),
|
|
]);
|
|
|
|
return (
|
|
<ProfileClient
|
|
user={user}
|
|
enabledProviders={enabledProviders}
|
|
apiTokens={apiTokens}
|
|
/>
|
|
);
|
|
}
|