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, getAsset } 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 DELETE(_request: Request, context: { params: Promise<{ id: string }> }) {
try {
const user = await requireAppUser();
const { id } = await context.params;
const asset = await getAsset(id);
if (!asset) return jsonError("资产不存在", 404);
if (!asset || asset.ownerId !== user.id) return jsonError("资产不存在", 404);
await deleteStoredAsset(asset);
await deleteAsset(id);
return jsonOk({ ok: true, deletedAssetId: id });