Skip to content

Commit 6aca4be

Browse files
authored
fix: ranked and comp unbans are synced
1 parent 9fa4b37 commit 6aca4be

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

modules/redis.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,10 @@ async function cacheUserPermissions(userId) {
13691369
);
13701370
var groups = inGroups.map((inGroup) => inGroup.toJSON().group);
13711371

1372-
var bans = await models.Ban.find({ userId: userId }).select("permissions");
1372+
var bans = await models.Ban.find({
1373+
userId: userId,
1374+
$or: [{ expires: 0 }, { expires: { $gt: Date.now() } }],
1375+
}).select("permissions");
13731376

13741377
var perms = {};
13751378
var maxRank = user.rank || 0;

routes/game.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ router.get("/:id/connect", async function (req, res) {
319319
if (
320320
userId &&
321321
game.settings.competitive &&
322-
!(await routeUtils.verifyPermission(userId, "playRanked"))
322+
!(await routeUtils.verifyPermission(userId, "playCompetitive"))
323323
) {
324324
res.status(500);
325325
res.send(
@@ -692,15 +692,15 @@ router.post("/host", async function (req, res) {
692692
}
693693

694694
if (
695-
req.body.competitive &&
696-
!(await routeUtils.verifyPermission(userId, "playRanked"))
697-
) {
698-
res.status(500);
699-
res.send(
700-
"You are unable to play competitive games. Please contact an admin if this is in error."
701-
);
702-
return;
703-
}
695+
req.body.competitive &&
696+
!(await routeUtils.verifyPermission(userId, "playCompetitive"))
697+
) {
698+
res.status(500);
699+
res.send(
700+
"You are unable to play competitive games. Please contact an admin if this is in error."
701+
);
702+
return;
703+
}
704704

705705
const user = await redis.getUserInfo(userId);
706706
if (req.body.ranked) {

routes/mod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ router.post("/ban", async (req, res) => {
530530
chat: ["publicChat", "privateChat"],
531531
game: ["playGame"],
532532
ranked: ["playRanked", "playCompetitive"],
533-
competitive: ["playRanked", "playCompetitive"],
533+
competitive: ["playCompetitive"],
534534
site: ["signIn"],
535535
};
536536

0 commit comments

Comments
 (0)