fix
Browse files
index.js
CHANGED
@@ -298,6 +298,7 @@ app.post("/api/v1/revoked-key", async (req, res) => {
|
|
298 |
}
|
299 |
});
|
300 |
|
|
|
301 |
app.post("/api/v1/api-key-unban", async (req, res) => {
|
302 |
const dbClient = new Database("AkenoXJs");
|
303 |
const collection = dbClient.collection("api_keys");
|
@@ -344,6 +345,18 @@ app.post("/api/v1/api-key-unban", async (req, res) => {
|
|
344 |
}
|
345 |
});
|
346 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
app.post("/api/v1/api-key-ban", async (req, res) => {
|
348 |
const dbClient = new Database("AkenoXJs");
|
349 |
const collection = dbClient.collection("api_keys");
|
@@ -370,6 +383,10 @@ app.post("/api/v1/api-key-ban", async (req, res) => {
|
|
370 |
return res.status(404).json({ error: "API key not found" });
|
371 |
}
|
372 |
|
|
|
|
|
|
|
|
|
373 |
const result = await collection.updateOne(
|
374 |
{ owner: userIdNumber },
|
375 |
{ $set: { is_banned: true } },
|
|
|
298 |
}
|
299 |
});
|
300 |
|
301 |
+
|
302 |
app.post("/api/v1/api-key-unban", async (req, res) => {
|
303 |
const dbClient = new Database("AkenoXJs");
|
304 |
const collection = dbClient.collection("api_keys");
|
|
|
345 |
}
|
346 |
});
|
347 |
|
348 |
+
app.get("/api/v1/apikey-banlist", async (req, res) => {
|
349 |
+
const dbClient = new Database("AkenoXJs");
|
350 |
+
const collection = dbClient.collection("api_keys");
|
351 |
+
|
352 |
+
try {
|
353 |
+
const bannedKeys = await collection.find({ is_banned: true }).toArray();
|
354 |
+
res.json({ bannedKeys });
|
355 |
+
} catch (err) {
|
356 |
+
res.status(500).json({ error: `Failed to fetch banned keys: ${err.message}` });
|
357 |
+
}
|
358 |
+
});
|
359 |
+
|
360 |
app.post("/api/v1/api-key-ban", async (req, res) => {
|
361 |
const dbClient = new Database("AkenoXJs");
|
362 |
const collection = dbClient.collection("api_keys");
|
|
|
383 |
return res.status(404).json({ error: "API key not found" });
|
384 |
}
|
385 |
|
386 |
+
if (existingUser.is_banned === true) {
|
387 |
+
return res.status(400).json({ message: "API key is already banned" });
|
388 |
+
}
|
389 |
+
|
390 |
const result = await collection.updateOne(
|
391 |
{ owner: userIdNumber },
|
392 |
{ $set: { is_banned: true } },
|