feat: add authentication
This commit is contained in:
@ -10,7 +10,7 @@ import * as tmdb from "@lib/tmdb.ts";
|
||||
import { parse, stringify } from "https://deno.land/std@0.194.0/yaml/mod.ts";
|
||||
import { formatDate, safeFileName } from "@lib/string.ts";
|
||||
import { json } from "@lib/helpers.ts";
|
||||
import { BadRequestError } from "@lib/errors.ts";
|
||||
import { AccessDeniedError, BadRequestError } from "@lib/errors.ts";
|
||||
|
||||
async function updateMovieMetadata(
|
||||
name: string,
|
||||
@ -49,13 +49,18 @@ async function updateMovieMetadata(
|
||||
}
|
||||
|
||||
const POST = async (
|
||||
_req: Request,
|
||||
_ctx: HandlerContext,
|
||||
req: Request,
|
||||
ctx: HandlerContext,
|
||||
): Promise<Response> => {
|
||||
const movie = await getMovie(_ctx.params.name);
|
||||
const movie = await getMovie(ctx.params.name);
|
||||
|
||||
const body = await _req.json();
|
||||
const name = _ctx.params.name;
|
||||
const session = ctx.state.session;
|
||||
if (!session) {
|
||||
throw new AccessDeniedError();
|
||||
}
|
||||
|
||||
const body = await req.json();
|
||||
const name = ctx.params.name;
|
||||
const { tmdbId } = body;
|
||||
if (!name || !tmdbId) {
|
||||
throw new BadRequestError();
|
||||
|
Reference in New Issue
Block a user