Update middleware/midware.js
Browse files- middleware/midware.js +5 -4
middleware/midware.js
CHANGED
@@ -18,7 +18,6 @@ const authenticateApiKeyPremium = async (req, res, next) => {
|
|
18 |
EXTRA_ALLOWED_UA.some(allowed => ua?.startsWith(allowed));
|
19 |
|
20 |
if (!isAllowed) {
|
21 |
-
// console.log(ua);
|
22 |
return res.status(403).json({
|
23 |
status: "error",
|
24 |
message: "Access blocked: User-Agent not allowed",
|
@@ -46,7 +45,6 @@ const authenticateApiKeyPremium = async (req, res, next) => {
|
|
46 |
if (keyData.expiresAt && new Date() > keyData.expiresAt) {
|
47 |
keyData.is_expired = true;
|
48 |
await keyData.save();
|
49 |
-
// await TelegramUseLogNotif(keyData.owner, keyData.key);
|
50 |
return res.status(403).json({ error: 'Premium API Key has expired' });
|
51 |
}
|
52 |
|
@@ -91,10 +89,13 @@ const authenticateApiKey = async (req, res, next) => {
|
|
91 |
const db = dbClient.collection("api_keys");
|
92 |
const ua = req.headers['user-agent'];
|
93 |
|
94 |
-
|
|
|
|
|
|
|
95 |
return res.status(403).json({
|
96 |
status: "error",
|
97 |
-
message: "Access blocked:
|
98 |
});
|
99 |
}
|
100 |
|
|
|
18 |
EXTRA_ALLOWED_UA.some(allowed => ua?.startsWith(allowed));
|
19 |
|
20 |
if (!isAllowed) {
|
|
|
21 |
return res.status(403).json({
|
22 |
status: "error",
|
23 |
message: "Access blocked: User-Agent not allowed",
|
|
|
45 |
if (keyData.expiresAt && new Date() > keyData.expiresAt) {
|
46 |
keyData.is_expired = true;
|
47 |
await keyData.save();
|
|
|
48 |
return res.status(403).json({ error: 'Premium API Key has expired' });
|
49 |
}
|
50 |
|
|
|
89 |
const db = dbClient.collection("api_keys");
|
90 |
const ua = req.headers['user-agent'];
|
91 |
|
92 |
+
const isAllowed = ALLOWED_UA_REGEX.test(ua || "") ||
|
93 |
+
EXTRA_ALLOWED_UA.some(allowed => ua?.startsWith(allowed));
|
94 |
+
|
95 |
+
if (!isAllowed) {
|
96 |
return res.status(403).json({
|
97 |
status: "error",
|
98 |
+
message: "Access blocked: User-Agent not allowed",
|
99 |
});
|
100 |
}
|
101 |
|