Skip to content

Commit 551e103

Browse files
committed
add tregex for both patreon and gumroad
1 parent 8fc01ba commit 551e103

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/routes/verifyToken.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export async function verifyTokenRequest(req: VerifyTokenRequest, res: Response)
1818
if (!licenseKey) {
1919
return res.status(400).send("Invalid request");
2020
}
21+
const licenseRegex = new RegExp(/[a-zA-Z0-9]{40}|[A-Z0-9-]{35}/);
22+
if (!licenseRegex.test(licenseKey)) {
23+
return res.status(200).send({
24+
allowed: false
25+
});
26+
}
2127

2228
const tokens = (await privateDB.prepare("get", `SELECT "accessToken", "refreshToken", "expiresIn" from "oauthLicenseKeys" WHERE "licenseKey" = ?`
2329
, [licenseKey])) as {accessToken: string, refreshToken: string, expiresIn: number};
@@ -41,25 +47,13 @@ export async function verifyTokenRequest(req: VerifyTokenRequest, res: Response)
4147
}
4248
} else {
4349
// Check Local
44-
const localRegex = new RegExp(/[a-zA-Z0-9]{40}/);
45-
if (!localRegex.test(licenseKey)) {
46-
return res.status(200).send({
47-
allowed: false
48-
});
49-
}
5050
const result = await privateDB.prepare("get", `SELECT "licenseKey" from "licenseKeys" WHERE "licenseKey" = ?`, [licenseKey]);
5151
if (result) {
5252
return res.status(200).send({
5353
allowed: true
5454
});
5555
} else {
5656
// Gumroad
57-
const gumRoadRegex = new RegExp(/[A-Z0-9-]{35}/);
58-
if (gumRoadRegex.test(licenseKey)) { // check against regex
59-
return res.status(200).send({
60-
allowed: false
61-
});
62-
}
6357
return res.status(200).send({
6458
allowed: await checkAllGumroadProducts(licenseKey)
6559
});

0 commit comments

Comments
 (0)