Add authenticated login and SSO protection
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { getAsset } from "@/lib/server/data-store";
|
||||
import { jsonError, jsonOk, readJsonBody } from "@/lib/server/api";
|
||||
import { requireAppUser } from "@/lib/server/auth/current-user";
|
||||
import { requestOrigin } from "@/lib/server/runtime";
|
||||
import { submitImageJob } from "@/lib/server/generation-service";
|
||||
|
||||
@@ -7,14 +8,16 @@ export const runtime = "nodejs";
|
||||
|
||||
export async function POST(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(new Error("Asset not found."), 404);
|
||||
if (!asset || asset.ownerId !== user.id) return jsonError(new Error("Asset not found."), 404);
|
||||
const body = await readJsonBody<{
|
||||
resolution?: "4k" | "8k";
|
||||
scale?: number;
|
||||
}>(request);
|
||||
const job = await submitImageJob({
|
||||
ownerId: user.id,
|
||||
capability: "image.upscale",
|
||||
imageUrls: [asset.url],
|
||||
inputAssetIds: [asset.id],
|
||||
|
||||
Reference in New Issue
Block a user