mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-02-20 12:19:03 +00:00
feat: perms.group() to get user's group name
This commit is contained in:
parent
b4e32a6001
commit
5d3ef6e566
@ -6,8 +6,22 @@ self.permissions = Object.freeze({
|
||||
admin: 80, // Manage users (disable accounts) & create moderators
|
||||
superadmin: 100 // Create admins
|
||||
// Groups will inherit permissions from groups which have lower value
|
||||
// You should NOT have multiple groups with exact same values
|
||||
})
|
||||
|
||||
self.keys = Object.freeze(Object.keys(self.permissions))
|
||||
|
||||
self.group = user => {
|
||||
// root bypass
|
||||
if (user.username === 'root') return 'superadmin'
|
||||
for (const key of self.keys) {
|
||||
if (user.permission === self.permissions[key]) {
|
||||
return key
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// returns true if user is in the group OR higher
|
||||
self.is = (user, group) => {
|
||||
// root bypass
|
||||
|
Loading…
Reference in New Issue
Block a user