revert un-needed refactor (2)
This commit is contained in:
parent
3747708eb5
commit
9d6a667710
1 changed files with 2 additions and 4 deletions
|
|
@ -381,9 +381,7 @@ export class ApiCallService implements OnApplicationShutdown {
|
||||||
if ((ep.meta.requireModerator || ep.meta.requireAdmin) && (this.meta.rootUserId !== user?.id)) {
|
if ((ep.meta.requireModerator || ep.meta.requireAdmin) && (this.meta.rootUserId !== user?.id)) {
|
||||||
// Sync with UserEntityService
|
// Sync with UserEntityService
|
||||||
const myRoles = user ? await this.roleService.getUserRoles(user) : [];
|
const myRoles = user ? await this.roleService.getUserRoles(user) : [];
|
||||||
const isAdmin = myRoles.some(r => r.isAdministrator) && (token?.rank == null || token.rank === 'admin');
|
if (ep.meta.requireModerator && !myRoles.some(r => r.isModerator || r.isAdministrator)) {
|
||||||
const isModerator = myRoles.some(r => r.isAdministrator || r.isModerator) && (token?.rank == null || token.rank === 'admin' || token.rank === 'mod');
|
|
||||||
if (ep.meta.requireModerator && !isModerator) {
|
|
||||||
throw new ApiError({
|
throw new ApiError({
|
||||||
message: 'You are not assigned to a moderator role.',
|
message: 'You are not assigned to a moderator role.',
|
||||||
code: 'ROLE_PERMISSION_DENIED',
|
code: 'ROLE_PERMISSION_DENIED',
|
||||||
|
|
@ -391,7 +389,7 @@ export class ApiCallService implements OnApplicationShutdown {
|
||||||
id: 'd33d5333-db36-423d-a8f9-1a2b9549da41',
|
id: 'd33d5333-db36-423d-a8f9-1a2b9549da41',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ep.meta.requireAdmin && !isAdmin) {
|
if (ep.meta.requireAdmin && !myRoles.some(r => r.isAdministrator)) {
|
||||||
throw new ApiError({
|
throw new ApiError({
|
||||||
message: 'You are not assigned to an administrator role.',
|
message: 'You are not assigned to an administrator role.',
|
||||||
code: 'ROLE_PERMISSION_DENIED',
|
code: 'ROLE_PERMISSION_DENIED',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue