Update middleware/midware.js
Browse files- middleware/midware.js +6 -1
middleware/midware.js
CHANGED
@@ -19,11 +19,16 @@ const authenticateApiKeyPremium = async (req, res, next) => {
|
|
19 |
return res.status(403).json({ error: 'Invalid or non-premium API Key' });
|
20 |
}
|
21 |
|
22 |
-
if (keyData.is_banned
|
23 |
return res.status(403).json({ error: 'Banned API Key' });
|
24 |
}
|
25 |
|
|
|
|
|
|
|
|
|
26 |
if (keyData.expiresAt && new Date() > keyData.expiresAt) {
|
|
|
27 |
await TelegramUseLogNotif(keyData.owner, keyData.key);
|
28 |
return res.status(403).json({ error: 'Premium API Key has expired' });
|
29 |
}
|
|
|
19 |
return res.status(403).json({ error: 'Invalid or non-premium API Key' });
|
20 |
}
|
21 |
|
22 |
+
if (keyData.is_banned) {
|
23 |
return res.status(403).json({ error: 'Banned API Key' });
|
24 |
}
|
25 |
|
26 |
+
if (keyData.is_expired) {
|
27 |
+
return res.status(403).json({ error: 'API Key is expired' });
|
28 |
+
}
|
29 |
+
|
30 |
if (keyData.expiresAt && new Date() > keyData.expiresAt) {
|
31 |
+
await keyData.updateOne({ is_expired: true });
|
32 |
await TelegramUseLogNotif(keyData.owner, keyData.key);
|
33 |
return res.status(403).json({ error: 'Premium API Key has expired' });
|
34 |
}
|