Add permissionsToJson

This commit is contained in:
SeanOMik 2020-06-18 18:05:09 -05:00
parent ddfa53805a
commit 0af96d238d
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
1 changed files with 14 additions and 1 deletions

View File

@ -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")