Add authenticated login and SSO protection

This commit is contained in:
inman
2026-05-29 15:54:13 +08:00
parent e36f28a668
commit 0648874801
50 changed files with 1853 additions and 63 deletions

View File

@@ -1,14 +1,16 @@
import { deleteAsset, deleteGenerationJob, getAsset, getGenerationJob } from "@/lib/server/data-store";
import { jsonError, jsonOk } from "@/lib/server/api";
import { requireAppUser } from "@/lib/server/auth/current-user";
import { deleteStoredAsset } from "@/lib/server/storage";
export const runtime = "nodejs";
export async function GET(_request: Request, context: { params: Promise<{ id: string }> }) {
try {
const user = await requireAppUser();
const { id } = await context.params;
const job = await getGenerationJob(id);
if (!job) return jsonError(new Error("Generation job not found."), 404);
if (!job || job.ownerId !== user.id) return jsonError(new Error("Generation job not found."), 404);
return jsonOk({ job });
} catch (error) {
return jsonError(error, 500);
@@ -17,9 +19,10 @@ export async function GET(_request: Request, context: { params: Promise<{ id: st
export async function DELETE(_request: Request, context: { params: Promise<{ id: string }> }) {
try {
const user = await requireAppUser();
const { id } = await context.params;
const job = await getGenerationJob(id);
if (!job || job.capability !== "video.generate") return jsonError("任务不存在", 404);
if (!job || job.ownerId !== user.id || job.capability !== "video.generate") return jsonError("任务不存在", 404);
const deletedAssetIds: string[] = [];
for (const assetId of job.outputAssetIds) {
const asset = await getAsset(assetId);