Add permissionsToJson
This commit is contained in:
parent
ddfa53805a
commit
0af96d238d
|
@ -80,4 +80,17 @@ proc addDenyPermission*(perms: Permissions, perm: Permission): Permissions =
|
||||||
if ((perms.allowPerms and uint(perm)) == uint(perm)):
|
if ((perms.allowPerms and uint(perm)) == uint(perm)):
|
||||||
perms.allowPerms = perms.allowPerms and (not uint(perm))
|
perms.allowPerms = perms.allowPerms and (not uint(perm))
|
||||||
|
|
||||||
perms.denyPerms = perms.denyPerms or uint(perm)
|
perms.denyPerms = perms.denyPerms or uint(perm)
|
||||||
|
|
||||||
|
proc permissionsToJson*(perms: Permissions): JsonNode =
|
||||||
|
## Convert `Permissions` to json.
|
||||||
|
let json = %* {
|
||||||
|
"id": perms.roleUserID,
|
||||||
|
"allow": perms.allowPerms,
|
||||||
|
"deny": perms.denyPerms
|
||||||
|
}
|
||||||
|
|
||||||
|
if (perms.permissionType == PermissionType.permTypeMember):
|
||||||
|
json.add("type", %"member")
|
||||||
|
else:
|
||||||
|
json.add("type", %"role")
|
Reference in New Issue