Update index.js
Browse files
index.js
CHANGED
@@ -400,7 +400,29 @@ app.post("/api/v1/key/api-key-ban", authenticateApiKey, apiLimiter, async (req,
|
|
400 |
const existingUser = await collection.findOne({ owner: userIdNumber });
|
401 |
|
402 |
if (!existingUser || !existingUserTwo) {
|
403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
}
|
405 |
|
406 |
if (existingUser.is_banned === true || existingUserTwo.is_banned === true) {
|
|
|
400 |
const existingUser = await collection.findOne({ owner: userIdNumber });
|
401 |
|
402 |
if (!existingUser || !existingUserTwo) {
|
403 |
+
const userDocument = {
|
404 |
+
key: null,
|
405 |
+
createdAt: new Date(),
|
406 |
+
owner: userIdNumber,
|
407 |
+
type: "free",
|
408 |
+
is_banned: true,
|
409 |
+
username: null,
|
410 |
+
};
|
411 |
+
const userDocumentTwo = new ApiKey({
|
412 |
+
key: null,
|
413 |
+
createdAt: new Date(),
|
414 |
+
expiresAt: null,
|
415 |
+
owner: userIdNumber,
|
416 |
+
type: "premium",
|
417 |
+
is_banned: true,
|
418 |
+
email: null
|
419 |
+
});
|
420 |
+
await userDocumentTwo.save();
|
421 |
+
await collection.insertOne(userDocument);
|
422 |
+
return res.status(200).json({
|
423 |
+
message: "API key successfully banned",
|
424 |
+
owner: userIdNumber
|
425 |
+
});
|
426 |
}
|
427 |
|
428 |
if (existingUser.is_banned === true || existingUserTwo.is_banned === true) {
|