Reimplmented the old permission checking system

ref #6
This commit is contained in:
Nicolai Ort 2020-12-18 17:15:44 +01:00
parent b9e91502cd
commit 6237e62a03
1 changed files with 10 additions and 1 deletions

View File

@ -26,7 +26,16 @@ const authchecker = async (action: Action, permissions: string[] | string) => {
action.response.local = {}
action.response.local.jwtPayload = jwtPayload.permissions
//TODO: Check Permissions
required_permissions.forEach(r => {
const permission_key = r.split(":")[0]
const actual_accesslevel_for_permission = jwtPayload.permissions[permission_key]
const permission_access_level = r.split(":")[1]
if (actual_accesslevel_for_permission.includes(permission_access_level)) {
return true;
} else {
throw new NoPermissionError()
}
});
try {
jwt.verify(provided_token, config.jwt_secret);
return true