This commit is contained in:
syuilo 2023-01-13 14:46:56 +09:00
parent 54ff4e53cb
commit 0a6e237d09
3 changed files with 14 additions and 7 deletions

View file

@ -271,6 +271,17 @@ export class ApiCallService implements OnApplicationShutdown {
}
}
if (ep.meta.requireRoleOption != null && !user!.isRoot) {
const myRole = await this.roleService.getUserRoleOptions(user!.id);
if (!myRole[ep.meta.requireRoleOption]) {
throw new ApiError({
message: 'You are not assigned to a required role.',
code: 'ROLE_PERMISSION_DENIED',
id: '7f86f06f-7e15-4057-8561-f4b6d4ac755a',
});
}
}
if (token && ep.meta.kind && !token.permission.some(p => p === ep.meta.kind)) {
throw new ApiError({
message: 'Your app does not have the necessary permissions to use this endpoint.',