Skip to content

Commit 1ce80d1

Browse files
committed
Switch banning to use a new banned property on users
1 parent b131906 commit 1ce80d1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/common.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ module.exports = (config) => {
155155

156156
const _id = user._id
157157
if (!remove) {
158-
if (user.active === 0) {
158+
if (user.banned) {
159159
return `User "${username}" ${_id} is already banned.`
160160
}
161-
await db.users.update({ _id }, { $set: { active: 0 } })
161+
await db.users.update({ _id }, { $set: { active: 0, banned: true } })
162162
console.log(`Suspended user "${username}" ${_id}`)
163163
return `Suspended user "${username}" ${_id}`
164164
} else {
@@ -180,7 +180,7 @@ module.exports = (config) => {
180180
return `User "${username}" ${user._id} is not banned.`
181181
}
182182

183-
await db.users.update({ _id: user._id }, { $set: { active: 10000 } })
183+
await db.users.update({ _id: user._id }, { $set: { active: 10000, banned: false } })
184184
console.log(`Unbanned user "${username}" ${user._id}`)
185185
return `Unbanned user "${username}" ${user._id}`
186186
}

lib/services/whitelist/cronjobs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = (config) => {
55
const WHITELIST = JSON.parse(await env.get(env.keys.WHITELIST) || '[]').map(u => u.toLowerCase())
66
const users = await db.users.find()
77
for (const user of users) {
8-
const blocked = !(user.allowed || WHITELIST.length === 0 || (user.username && WHITELIST.includes(user.username.toLowerCase())))
8+
const blocked = !(user.allowed || !user.banned || WHITELIST.length === 0 || (user.username && WHITELIST.includes(user.username.toLowerCase())))
99
db.users.update({ _id: user._id }, { $set: { blocked } })
1010
}
1111
}]

0 commit comments

Comments
 (0)