mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-16 16:37:12 +03:00
fix tokenUtils tests, skip if not configured
This commit is contained in:
@@ -12,11 +12,19 @@ interface VerifyTokenRequest extends Request {
|
||||
}
|
||||
}
|
||||
|
||||
export const validatelicenseKeyRegex = (token: string) =>
|
||||
new RegExp(/[A-Za-z0-9]{40}/).test(token);
|
||||
|
||||
export async function verifyTokenRequest(req: VerifyTokenRequest, res: Response): Promise<Response> {
|
||||
const { query: { licenseKey } } = req;
|
||||
|
||||
if (!licenseKey) {
|
||||
return res.status(400).send("Invalid request");
|
||||
} else if (!validatelicenseKeyRegex(licenseKey)) {
|
||||
// fast check for invalid licence key
|
||||
return res.status(200).send({
|
||||
allowed: false
|
||||
});
|
||||
}
|
||||
const licenseRegex = new RegExp(/[a-zA-Z0-9]{40}|[A-Z0-9-]{35}/);
|
||||
if (!licenseRegex.test(licenseKey)) {
|
||||
|
||||
Reference in New Issue
Block a user