revert un-needed refactor (2)

This commit is contained in:
Hazelnoot 2025-06-22 15:41:52 -04:00
parent 3747708eb5
commit 9d6a667710

View file

@ -381,9 +381,7 @@ export class ApiCallService implements OnApplicationShutdown {
if ((ep.meta.requireModerator || ep.meta.requireAdmin) && (this.meta.rootUserId !== user?.id)) {
// Sync with UserEntityService
const myRoles = user ? await this.roleService.getUserRoles(user) : [];
const isAdmin = myRoles.some(r => r.isAdministrator) && (token?.rank == null || token.rank === 'admin');
const isModerator = myRoles.some(r => r.isAdministrator || r.isModerator) && (token?.rank == null || token.rank === 'admin' || token.rank === 'mod');
if (ep.meta.requireModerator && !isModerator) {
if (ep.meta.requireModerator && !myRoles.some(r => r.isModerator || r.isAdministrator)) {
throw new ApiError({
message: 'You are not assigned to a moderator role.',
code: 'ROLE_PERMISSION_DENIED',
@ -391,7 +389,7 @@ export class ApiCallService implements OnApplicationShutdown {
id: 'd33d5333-db36-423d-a8f9-1a2b9549da41',
});
}
if (ep.meta.requireAdmin && !isAdmin) {
if (ep.meta.requireAdmin && !myRoles.some(r => r.isAdministrator)) {
throw new ApiError({
message: 'You are not assigned to an administrator role.',
code: 'ROLE_PERMISSION_DENIED',