update
Browse files
index.js
CHANGED
@@ -207,6 +207,43 @@ app.get("/runtime", async (req, res) => {
|
|
207 |
res.send("Running lifetime");
|
208 |
})
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
app.post('/api/v2/generate-key', async (req, res) => {
|
211 |
try {
|
212 |
const newKey = generateAkenoKey();
|
|
|
207 |
res.send("Running lifetime");
|
208 |
})
|
209 |
|
210 |
+
app.post("/api/v2/api-key-ban", async (req, res) => {
|
211 |
+
const userIdNumber = Number(req.query.user_id);
|
212 |
+
|
213 |
+
if (isNaN(userIdNumber)) {
|
214 |
+
return res.status(400).json({ error: "Invalid or missing user_id" });
|
215 |
+
}
|
216 |
+
|
217 |
+
if (userIdNumber === 0) {
|
218 |
+
return res.status(400).json({ error: "Invalid user_id" });
|
219 |
+
}
|
220 |
+
const existingUser = await ApiKey.findOne({ owner: userIdNumber });
|
221 |
+
|
222 |
+
if (!existingUser) {
|
223 |
+
return res.status(404).json({ error: "API key not found" });
|
224 |
+
}
|
225 |
+
|
226 |
+
if (existingUser.is_banned === true) {
|
227 |
+
return res.status(400).json({ message: "API key is already banned" });
|
228 |
+
}
|
229 |
+
|
230 |
+
const result = await ApiKey.updateOne(
|
231 |
+
{ owner: userIdNumber },
|
232 |
+
{ $set: { is_banned: true } },
|
233 |
+
{ upsert: false }
|
234 |
+
);
|
235 |
+
|
236 |
+
if (result.matchedCount > 0) {
|
237 |
+
res.json({
|
238 |
+
message: "API v2 key successfully banned",
|
239 |
+
owner: userIdNumber
|
240 |
+
});
|
241 |
+
} else {
|
242 |
+
res.status(500).json({ error: "Failed to ban API key" });
|
243 |
+
}
|
244 |
+
});
|
245 |
+
|
246 |
+
|
247 |
app.post('/api/v2/generate-key', async (req, res) => {
|
248 |
try {
|
249 |
const newKey = generateAkenoKey();
|