Skip to content

Commit b52ca8b

Browse files
authored
Merge pull request #513 from mchangrh/tokenValidation
add additional token validation
2 parents 415bb31 + e799821 commit b52ca8b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/routes/generateToken.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Request, Response } from "express";
22
import { config } from "../config";
33
import { createAndSaveToken, TokenType } from "../utils/tokenUtils";
4-
4+
import { getHashCache } from "../utils/getHashCache";
55

66
interface GenerateTokenRequest extends Request {
77
query: {
@@ -15,12 +15,13 @@ interface GenerateTokenRequest extends Request {
1515

1616
export async function generateTokenRequest(req: GenerateTokenRequest, res: Response): Promise<Response> {
1717
const { query: { code, adminUserID }, params: { type } } = req;
18+
const adminUserIDHash = await getHashCache(adminUserID);
1819

1920
if (!code || !type) {
2021
return res.status(400).send("Invalid request");
2122
}
2223

23-
if (type === TokenType.patreon || (type === TokenType.local && adminUserID === config.adminUserID)) {
24+
if (type === TokenType.patreon || (type === TokenType.local && adminUserIDHash === config.adminUserID)) {
2425
const licenseKey = await createAndSaveToken(type, code);
2526

2627
if (licenseKey) {

0 commit comments

Comments
 (0)