parent
b9e91502cd
commit
6237e62a03
@ -26,7 +26,16 @@ const authchecker = async (action: Action, permissions: string[] | string) => {
|
|||||||
|
|
||||||
action.response.local = {}
|
action.response.local = {}
|
||||||
action.response.local.jwtPayload = jwtPayload.permissions
|
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 {
|
try {
|
||||||
jwt.verify(provided_token, config.jwt_secret);
|
jwt.verify(provided_token, config.jwt_secret);
|
||||||
return true
|
return true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user