@opengis/fastify-table 1.2.14 → 1.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ import applyHook from '../../hook/funcs/applyHook.js';
|
|
|
13
13
|
* @returns { scope: String, actions: String[], query: String }
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
const q = `select a.route_id as id,
|
|
16
|
+
const q = `select a.route_id as id, d.actions as user_roles, d.actions as role_actions, coalesce(b.actions, array['view']) as interface_actions, b.scope, c.role_id
|
|
17
17
|
from admin.routes a
|
|
18
18
|
left join admin.role_access b on
|
|
19
19
|
a.route_id=b.route_id
|
|
@@ -73,7 +73,10 @@ export default async function getAccess({ table, user = {} }) {
|
|
|
73
73
|
: {};
|
|
74
74
|
|
|
75
75
|
const query = userAccess?.scope === 'my' ? `uid='${uid}'` : '1=1';
|
|
76
|
-
const actions = userAccess?.
|
|
76
|
+
const actions = userAccess?.interface_actions
|
|
77
|
+
?.filter?.((el, idx, arr) => arr.indexOf(el) === idx)
|
|
78
|
+
?.filter(el => userAccess?.role_actions?.length ? userAccess?.role_actions.includes(el) : true)
|
|
79
|
+
?.filter(el => tableActions.includes(el));
|
|
77
80
|
return {
|
|
78
81
|
scope: userAccess?.scope,
|
|
79
82
|
roles: userAccess?.roles,
|
|
@@ -12,7 +12,7 @@ export default async function getSelectMeta({ name, pg = pgClients.client, nocac
|
|
|
12
12
|
if (selectMeta[name] && !nocache) return selectMeta[name];
|
|
13
13
|
|
|
14
14
|
const cls = await getSelect(name, pg);
|
|
15
|
-
const db = typeof cls
|
|
15
|
+
const db = typeof cls?.db === 'string' ? { database: cls.db } : cls?.db;
|
|
16
16
|
const pg1 = cls?.db ? getPG(db) : pg;
|
|
17
17
|
if (!pg1?.pk) await pg1.init();
|
|
18
18
|
|