Update plugins/antiban.js
Browse files- plugins/antiban.js +22 -0
plugins/antiban.js
CHANGED
@@ -310,6 +310,28 @@ AntibanRoutes.get("/api/v1/user/creation-date", authenticateApiKey, apiLimiter,
|
|
310 |
res.json({ user_id: userId, estimated_creation: result });
|
311 |
});
|
312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
/**
|
314 |
* @swagger
|
315 |
* /api/v1/user/ban-user:
|
|
|
310 |
res.json({ user_id: userId, estimated_creation: result });
|
311 |
});
|
312 |
|
313 |
+
AntibanRoutes.get("/api/v1/user/api-key-info", apiLimiter, async (req, res) => {
|
314 |
+
const dbClient = new Database("AkenoXJs");
|
315 |
+
const collectionKey = dbClient.collection("api_keys");
|
316 |
+
const apiKey = req.query.api_key
|
317 |
+
try {
|
318 |
+
if (!apiKey) {
|
319 |
+
return res.status(400).json({ error: "Missing API key" });
|
320 |
+
}
|
321 |
+
const existingUserKey = await collectionKey.findOne({ key: apiKey });
|
322 |
+
if (!existingUserKey) {
|
323 |
+
return res.status(401).json({ message: "API key not found" });
|
324 |
+
}
|
325 |
+
res.json({
|
326 |
+
owner_id: existingUserKey.owner,
|
327 |
+
key: existingUserKey.key,
|
328 |
+
ip_addresses: existingUserKey.ip_addresses || null;
|
329 |
+
});
|
330 |
+
} catch (error) {
|
331 |
+
res.status(500).json({ error: "Failed to fetch user info" });
|
332 |
+
}
|
333 |
+
});
|
334 |
+
|
335 |
/**
|
336 |
* @swagger
|
337 |
* /api/v1/user/ban-user:
|