randydev commited on
Commit
d584fea
·
verified ·
1 Parent(s): 39000f4

Update plugins/antiban.js

Browse files
Files changed (1) hide show
  1. plugins/antiban.js +15 -0
plugins/antiban.js CHANGED
@@ -3,6 +3,8 @@ import { Database } from '../database/database.js';
3
  import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
4
  const AntibanRoutes = express.Router();
5
 
 
 
6
  AntibanRoutes.post("/api/v1/user/ban-user", authenticateApiKey, apiLimiter, async (req, res) => {
7
  const dbClient = new Database("AkenoXJs");
8
  const collection = dbClient.collection("ban_users");
@@ -26,6 +28,19 @@ AntibanRoutes.post("/api/v1/user/ban-user", authenticateApiKey, apiLimiter, asyn
26
  return res.status(401).json({ message: "API key not found" });
27
  }
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  const existingBan = await collection.findOne({ user_ban: userIdNumber });
30
  if (existingBan) {
31
  return res.status(200).json({ message: `User ${userIdNumber} is already banned`, is_ban: true });
 
3
  import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
4
  const AntibanRoutes = express.Router();
5
 
6
+ const protectedUsers = [6477856957, 1191668125, 1448273246, 1054295664];
7
+
8
  AntibanRoutes.post("/api/v1/user/ban-user", authenticateApiKey, apiLimiter, async (req, res) => {
9
  const dbClient = new Database("AkenoXJs");
10
  const collection = dbClient.collection("ban_users");
 
28
  return res.status(401).json({ message: "API key not found" });
29
  }
30
 
31
+ if (existingUserKey.owner === userIdNumber) {
32
+ return res.status(200).json({
33
+ message: `User ${userIdNumber} cannot be banned because they created the API key`,
34
+ is_ban: false
35
+ });
36
+ }
37
+ if (protectedUsers.includes(userIdNumber)) {
38
+ return res.status(403).json({
39
+ message: `User ${userIdNumber} is a protected admin and cannot be banned`,
40
+ is_ban: false
41
+ });
42
+ }
43
+
44
  const existingBan = await collection.findOne({ user_ban: userIdNumber });
45
  if (existingBan) {
46
  return res.status(200).json({ message: `User ${userIdNumber} is already banned`, is_ban: true });