fix: list routes answer for permitted orgs only; org lists go through the hooks
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import type { Pool } from 'pg';
|
||||
import type { CheckLimitFn, RoleEventSink } from '../plugin.js';
|
||||
import { getUser, getOrgScope, hasPermission, SYSTEM_ORG_ID } from '../permissions.js';
|
||||
import { getUser, getOrgScope, hasPermission, permittedScope, SYSTEM_ORG_ID } from '../permissions.js';
|
||||
import { roleResponse, notFound, forbidden, unauthorized, badRequest } from '../schemas.js';
|
||||
import { loadProfile, validateGrantable, applyProfileRules } from './profile-apply.js';
|
||||
|
||||
@@ -58,7 +58,8 @@ export function createPermissionProfileRoutes(db: Pool, checkLimit?: CheckLimitF
|
||||
|
||||
const orgIds = getOrgScope(req, reply, false);
|
||||
if (orgIds === null) return reply;
|
||||
if (!await hasPermission(db, req, reply, orgIds[0] ?? null, 'read', 'roles')) return reply;
|
||||
const scope = await permittedScope(db, req, reply, orgIds, 'read', 'roles');
|
||||
if (!scope) return reply;
|
||||
|
||||
const { module_id } = req.query as { module_id?: string };
|
||||
const { rows } = await db.query(
|
||||
|
||||
Reference in New Issue
Block a user