From e799821ad9c4da603a64ea95055fd35110eadf4d Mon Sep 17 00:00:00 2001 From: Michael C Date: Thu, 13 Oct 2022 00:59:34 -0400 Subject: [PATCH] add additional token validation --- src/routes/generateToken.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/routes/generateToken.ts b/src/routes/generateToken.ts index 4c0771e..46069e0 100644 --- a/src/routes/generateToken.ts +++ b/src/routes/generateToken.ts @@ -1,7 +1,7 @@ import { Request, Response } from "express"; import { config } from "../config"; import { createAndSaveToken, TokenType } from "../utils/tokenUtils"; - +import { getHashCache } from "../utils/getHashCache"; interface GenerateTokenRequest extends Request { query: { @@ -15,12 +15,13 @@ interface GenerateTokenRequest extends Request { export async function generateTokenRequest(req: GenerateTokenRequest, res: Response): Promise { const { query: { code, adminUserID }, params: { type } } = req; + const adminUserIDHash = await getHashCache(adminUserID); if (!code || !type) { return res.status(400).send("Invalid request"); } - if (type === TokenType.patreon || (type === TokenType.local && adminUserID === config.adminUserID)) { + if (type === TokenType.patreon || (type === TokenType.local && adminUserIDHash === config.adminUserID)) { const licenseKey = await createAndSaveToken(type, code); if (licenseKey) {