Notifications interface (#5354)
Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import crypto from "crypto";
|
||||
import Router from "koa-router";
|
||||
import env from "@server/env";
|
||||
import { AuthenticationError } from "@server/errors";
|
||||
import validate from "@server/middlewares/validate";
|
||||
import tasks from "@server/queues/tasks";
|
||||
import { APIContext } from "@server/types";
|
||||
import { safeEqual } from "@server/utils/crypto";
|
||||
import * as T from "./schema";
|
||||
|
||||
const router = new Router();
|
||||
@@ -13,13 +13,7 @@ const cronHandler = async (ctx: APIContext<T.CronSchemaReq>) => {
|
||||
const token = (ctx.input.body.token ?? ctx.input.query.token) as string;
|
||||
const limit = ctx.input.body.limit ?? ctx.input.query.limit;
|
||||
|
||||
if (
|
||||
token.length !== env.UTILS_SECRET.length ||
|
||||
!crypto.timingSafeEqual(
|
||||
Buffer.from(env.UTILS_SECRET),
|
||||
Buffer.from(String(token))
|
||||
)
|
||||
) {
|
||||
if (!safeEqual(env.UTILS_SECRET, token)) {
|
||||
throw AuthenticationError("Invalid secret token");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user