@xeplr/auth 1.1.6 → 1.1.7
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/README.md +23 -1
- package/lib/accessService.js +50 -19
- package/lib/adminRouter.js +87 -0
- package/migrations/0013_mapping_state.sql +44 -0
- package/models/Api.js +1 -1
- package/models/ApisRolesMapping.js +1 -0
- package/models/MenuRolesMapping.js +1 -0
- package/models/Role.js +4 -4
- package/models/UiElementsRolesMapping.js +1 -0
- package/models/UiPagesRolesMapping.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -244,6 +244,7 @@ Auth's own migrations:
|
|
|
244
244
|
| `0010_system_scope` | `scope` (`system` / `company`) on `apis` and `roles`, `scopeLocked` on `apis`. Super Admin, the role-management routes and the scope switch become `system`; the routes are locked |
|
|
245
245
|
| `0011_verify_api` | the `GET /auth/api/verify` row, public in the catalog |
|
|
246
246
|
| `0012_default_role_access` | auth's own routes mapped to its default roles: `account:*` to every role, `users:*` `access:*` `settings:*` to Admin, system APIs to nobody but Super Admin |
|
|
247
|
+
| `0013_mapping_state` | `state` (`enabled` / `disabled`) on the four role-mapping tables, default `enabled`; the `module-states` and `module-state` rows, mapped to Super Admin and Admin |
|
|
247
248
|
|
|
248
249
|
## The first account
|
|
249
250
|
|
|
@@ -474,7 +475,28 @@ The gate answers one of three states, not true/false. Only `enabled` goes throug
|
|
|
474
475
|
|
|
475
476
|
Anything else is refused as well: a state the gate does not know never lets a request through.
|
|
476
477
|
|
|
477
|
-
`accessService.userApiState(userId, apiName)` gives the state; `userHasApiAccess` is still there and is true only for `enabled`.
|
|
478
|
+
`accessService.userApiState(userId, apiName)` gives the state; `userHasApiAccess` is still there and is true only for `enabled`.
|
|
479
|
+
|
|
480
|
+
Where each state comes from, for a role:
|
|
481
|
+
|
|
482
|
+
| state | stored as |
|
|
483
|
+
|---|---|
|
|
484
|
+
| `hidden` | no mapping row |
|
|
485
|
+
| `enabled` | a mapping row, `state = 'enabled'` (the default) |
|
|
486
|
+
| `disabled` | a mapping row, `state = 'disabled'` (`0013_mapping_state`) |
|
|
487
|
+
|
|
488
|
+
A user with several roles gets the most open answer: one role with it enabled is enough. Workspace and user overrides are not stored yet.
|
|
489
|
+
|
|
490
|
+
The access object leaves disabled items out of `apis`, `pages` and `elements` (what callers check) and lists them under `disabled: { apis, pages, elements, menus }`. A disabled menu stays in `menuItems` with `disabled: true`, so a UI can grey it out instead of dropping it.
|
|
491
|
+
|
|
492
|
+
Set from the Access Matrix, through two admin routes:
|
|
493
|
+
|
|
494
|
+
| route | |
|
|
495
|
+
|---|---|
|
|
496
|
+
| `GET /module-states?scope=role` | `[{ module, action, roleId, state: 'disabled' }]` for the roles the caller can see |
|
|
497
|
+
| `POST /module-state` | `{ scope: 'role', roleId, module, action, state }`: `disabled` greys out every item of that module/action the role is mapped to; `enabled`, `inherit` or `null` clears it. `hidden` is refused (`BAD_STATE`): hidden is removing the mapping, through `module-role` |
|
|
498
|
+
|
|
499
|
+
Any other `scope` answers `400 SCOPE_NOT_SUPPORTED`.
|
|
478
500
|
|
|
479
501
|
### Every request is checked
|
|
480
502
|
|
package/lib/accessService.js
CHANGED
|
@@ -42,21 +42,31 @@ async function getUserAccess(userId) {
|
|
|
42
42
|
const menuRows = [];
|
|
43
43
|
const elements = new Set();
|
|
44
44
|
|
|
45
|
+
// A DISABLED mapping (the row's state) is shown but not usable: it stays
|
|
46
|
+
// out of apis / pages / elements, which is what callers check, and is
|
|
47
|
+
// listed under `disabled` instead. A menu stays on the rail, marked
|
|
48
|
+
// disabled, so the UI can grey it out rather than drop it.
|
|
49
|
+
const disabledApis = new Set();
|
|
50
|
+
const disabledPages = new Set();
|
|
51
|
+
const disabledElements = new Set();
|
|
52
|
+
const disabledMenus = new Set();
|
|
53
|
+
const enabledMenus = new Set();
|
|
54
|
+
function sortInto(rows, enabled, disabled) {
|
|
55
|
+
for (const row of rows || []) {
|
|
56
|
+
if (row.state === 'disabled') disabled.add(row.name);
|
|
57
|
+
else enabled.add(row.name);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
45
61
|
for (const role of user.roles) {
|
|
46
62
|
roleNames.add(role.name);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (role.uiPages) {
|
|
52
|
-
for (const page of role.uiPages) pages.add(page.name);
|
|
53
|
-
}
|
|
63
|
+
sortInto(role.apis, apis, disabledApis);
|
|
64
|
+
sortInto(role.uiPages, pages, disabledPages);
|
|
65
|
+
sortInto(role.uiElements, elements, disabledElements);
|
|
66
|
+
sortInto(role.menus, enabledMenus, disabledMenus);
|
|
54
67
|
if (role.menus) {
|
|
55
68
|
for (const menu of role.menus) menuRows.push(menu);
|
|
56
69
|
}
|
|
57
|
-
if (role.uiElements) {
|
|
58
|
-
for (const el of role.uiElements) elements.add(el.name);
|
|
59
|
-
}
|
|
60
70
|
}
|
|
61
71
|
|
|
62
72
|
// Add public items
|
|
@@ -66,7 +76,12 @@ async function getUserAccess(userId) {
|
|
|
66
76
|
// Rows, not just names: a hidden item is left out, and each keeps its label
|
|
67
77
|
// and position. Caches written before labels existed carry names only.
|
|
68
78
|
for (const menu of publicItems.menuItems || publicItems.menus.map((name) => ({ name }))) menuRows.push(menu);
|
|
69
|
-
const
|
|
79
|
+
for (const name of publicItems.menus || []) enabledMenus.add(name);
|
|
80
|
+
// Enabled through any role (or public) beats disabled through another.
|
|
81
|
+
const menuItems = visibleItems(menuRows).map(function(m) {
|
|
82
|
+
return (disabledMenus.has(m.name) && !enabledMenus.has(m.name)) ? Object.assign({}, m, { disabled: true }) : m;
|
|
83
|
+
});
|
|
84
|
+
function notIn(set, enabled) { return [...set].filter(function(n) { return !enabled.has(n); }); }
|
|
70
85
|
|
|
71
86
|
const access = {
|
|
72
87
|
roles: [...roleNames],
|
|
@@ -76,7 +91,14 @@ async function getUserAccess(userId) {
|
|
|
76
91
|
menus: menuItems.map((m) => m.name),
|
|
77
92
|
// What to SHOW for each key, in rail order: [{ name, label, sortOrder }].
|
|
78
93
|
menuItems,
|
|
79
|
-
elements: [...elements]
|
|
94
|
+
elements: [...elements],
|
|
95
|
+
// Shown greyed out, not usable: { apis, pages, elements, menus } names.
|
|
96
|
+
disabled: {
|
|
97
|
+
apis: notIn(disabledApis, apis),
|
|
98
|
+
pages: notIn(disabledPages, pages),
|
|
99
|
+
elements: notIn(disabledElements, elements),
|
|
100
|
+
menus: notIn(disabledMenus, enabledMenus)
|
|
101
|
+
}
|
|
80
102
|
};
|
|
81
103
|
|
|
82
104
|
await cache.set(userAccessKey(userId), access, USER_ACCESS_TTL);
|
|
@@ -127,12 +149,17 @@ async function getApiRule(apiName) {
|
|
|
127
149
|
return rule;
|
|
128
150
|
}
|
|
129
151
|
|
|
130
|
-
|
|
152
|
+
// roleIds: roles that may use it. disabledRoleIds: roles that see it
|
|
153
|
+
// greyed out (the mapping row's state). Unmapped only when neither has any.
|
|
154
|
+
var mapped = api.roles || [];
|
|
155
|
+
var roleIds = mapped.filter(function(r) { return r.state !== 'disabled'; }).map(function(r) { return r.id; });
|
|
156
|
+
var disabledRoleIds = mapped.filter(function(r) { return r.state === 'disabled'; }).map(function(r) { return r.id; });
|
|
131
157
|
const rule = {
|
|
132
158
|
exists: true,
|
|
133
159
|
isPublic: !!api.isPublic,
|
|
134
|
-
unmapped:
|
|
135
|
-
roleIds
|
|
160
|
+
unmapped: mapped.length === 0,
|
|
161
|
+
roleIds,
|
|
162
|
+
disabledRoleIds
|
|
136
163
|
};
|
|
137
164
|
|
|
138
165
|
await cache.set(cacheKey, rule, API_RULES_TTL);
|
|
@@ -146,9 +173,8 @@ async function getApiRule(apiName) {
|
|
|
146
173
|
* disabled shown, greyed out, not usable: the API refuses it
|
|
147
174
|
* hidden not shown: the API refuses it
|
|
148
175
|
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* stored states that produce it come next.
|
|
176
|
+
* A role mapping row decides: no row → hidden; a row → its state (enabled,
|
|
177
|
+
* or disabled from the Access Matrix). Several roles: the most open wins.
|
|
152
178
|
*/
|
|
153
179
|
var ACCESS_STATES = ['enabled', 'disabled', 'hidden'];
|
|
154
180
|
|
|
@@ -160,7 +186,12 @@ function apiStateFor(rule, userRoleIds) {
|
|
|
160
186
|
// Not registered in DB, or marked public, or no role mappings = open
|
|
161
187
|
if (!rule.exists || rule.isPublic || rule.unmapped) return 'enabled';
|
|
162
188
|
var userRoleSet = new Set(userRoleIds || []);
|
|
163
|
-
return
|
|
189
|
+
function holds(ids) { return (ids || []).some(function(id) { return userRoleSet.has(id); }); }
|
|
190
|
+
// One role that may use it is enough; disabled only when every role the
|
|
191
|
+
// user holds for it has it disabled.
|
|
192
|
+
if (holds(rule.roleIds)) return 'enabled';
|
|
193
|
+
if (holds(rule.disabledRoleIds)) return 'disabled';
|
|
194
|
+
return 'hidden';
|
|
164
195
|
}
|
|
165
196
|
|
|
166
197
|
/** The user's role ids, cached for the gate. */
|
package/lib/adminRouter.js
CHANGED
|
@@ -278,6 +278,93 @@ function createAdminRouter() {
|
|
|
278
278
|
}
|
|
279
279
|
});
|
|
280
280
|
|
|
281
|
+
// ─── Module states: DISABLED, per role ───
|
|
282
|
+
// Enabled and Hidden are the role mapping (module-role above). Disabled is
|
|
283
|
+
// the mapping row's `state`: the role still sees the item, greyed out, and
|
|
284
|
+
// the API refuses it. Only roles for now; a workspace or user override is
|
|
285
|
+
// not stored, and says so.
|
|
286
|
+
var STATE_TYPES = [
|
|
287
|
+
{ Model: Api, MappingModel: ApisRolesMapping, fk: 'apiId', groupField: 'apiGroup', table: 'apis', mapping: 'apisRolesMapping' },
|
|
288
|
+
{ Model: UiPage, MappingModel: UiPagesRolesMapping, fk: 'uiPageId', groupField: 'uiPagesGroup', table: 'uiPages', mapping: 'uiPagesRolesMapping' },
|
|
289
|
+
{ Model: UiElement, MappingModel: UiElementsRolesMapping, fk: 'uiElementId', groupField: 'uiElementsGroup', table: 'uiElements', mapping: 'uiElementsRolesMapping' },
|
|
290
|
+
{ Model: Menu, MappingModel: MenuRolesMapping, fk: 'menuId', groupField: 'menuGroup', table: 'menus', mapping: 'menuRolesMapping' }
|
|
291
|
+
];
|
|
292
|
+
|
|
293
|
+
function onlyRoleScope(req, res, scope) {
|
|
294
|
+
if (scope === 'role') return false;
|
|
295
|
+
res.status(400).json({ error: 'Only role states are stored so far', code: 'SCOPE_NOT_SUPPORTED' });
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// "configuration:access:view" → module "configuration:access", action "view".
|
|
300
|
+
function splitGroup(group) {
|
|
301
|
+
var i = String(group || '').lastIndexOf(':');
|
|
302
|
+
return i <= 0 ? null : { module: group.slice(0, i), action: group.slice(i + 1) };
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
router.get('/module-states', async function(req, res) {
|
|
306
|
+
try {
|
|
307
|
+
if (onlyRoleScope(req, res, req.query.scope)) return;
|
|
308
|
+
var roleIds = (await visibleRoles(req)).map(function(r) { return r.id; });
|
|
309
|
+
var seen = {};
|
|
310
|
+
var out = [];
|
|
311
|
+
for (var i = 0; i < STATE_TYPES.length; i++) {
|
|
312
|
+
var cfg = STATE_TYPES[i];
|
|
313
|
+
var rows = await cfg.MappingModel.query()
|
|
314
|
+
.select(cfg.mapping + '.roleId', cfg.table + '.' + cfg.groupField + ' as grp')
|
|
315
|
+
.join(cfg.table, cfg.table + '.id', cfg.mapping + '.' + cfg.fk)
|
|
316
|
+
.where(cfg.mapping + '.state', 'disabled')
|
|
317
|
+
.whereIn(cfg.mapping + '.roleId', roleIds);
|
|
318
|
+
rows.forEach(function(r) {
|
|
319
|
+
var g = splitGroup(r.grp);
|
|
320
|
+
var key = r.grp + '|' + r.roleId;
|
|
321
|
+
if (!g || seen[key]) return;
|
|
322
|
+
seen[key] = true;
|
|
323
|
+
out.push({ module: g.module, action: g.action, roleId: r.roleId, state: 'disabled' });
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
res.json(out);
|
|
327
|
+
} catch (err) {
|
|
328
|
+
res.status(500).json({ error: 'Something went wrong' });
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// { scope: 'role', roleId, module, action, state }. state 'disabled' greys
|
|
333
|
+
// out every item of that module/action the role is mapped to; 'enabled',
|
|
334
|
+
// 'inherit' or null clears it. Hidden is not a state to store: it is no
|
|
335
|
+
// mapping, set through module-role.
|
|
336
|
+
router.post('/module-state', async function(req, res) {
|
|
337
|
+
try {
|
|
338
|
+
var { scope, module: moduleName, action, roleId, state } = req.body || {};
|
|
339
|
+
if (onlyRoleScope(req, res, scope)) return;
|
|
340
|
+
if (!moduleName || !action || !roleId) {
|
|
341
|
+
return res.status(400).json({ error: 'module, action, and roleId are required' });
|
|
342
|
+
}
|
|
343
|
+
var next = (state === 'disabled') ? 'disabled' : (state == null || state === 'enabled' || state === 'inherit') ? 'enabled' : null;
|
|
344
|
+
if (!next) {
|
|
345
|
+
return res.status(400).json({ error: 'state must be disabled, enabled or inherit; hidden is removing the mapping', code: 'BAD_STATE' });
|
|
346
|
+
}
|
|
347
|
+
if (await refuseSystemRole(req, res, roleId)) return;
|
|
348
|
+
|
|
349
|
+
var groupValue = moduleName + ':' + action;
|
|
350
|
+
var changed = 0;
|
|
351
|
+
for (var i = 0; i < STATE_TYPES.length; i++) {
|
|
352
|
+
var cfg = STATE_TYPES[i];
|
|
353
|
+
var items = cfg.Model.query().select('id').where(cfg.groupField, groupValue);
|
|
354
|
+
if (cfg.table === 'apis') items = items.where('scope', '<>', 'system');
|
|
355
|
+
changed += await cfg.MappingModel.query()
|
|
356
|
+
.patch({ state: next, recordModifiedBy: req.user ? req.user.id : null })
|
|
357
|
+
.where('roleId', roleId)
|
|
358
|
+
.whereIn(cfg.fk, items);
|
|
359
|
+
}
|
|
360
|
+
// Every cached answer: the API rules and each user's access object.
|
|
361
|
+
await clearAllAccess();
|
|
362
|
+
res.json({ ok: true, changed: changed });
|
|
363
|
+
} catch (err) {
|
|
364
|
+
res.status(500).json({ error: 'Something went wrong' });
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
|
|
281
368
|
// ─── Master CRUD: Roles ───
|
|
282
369
|
router.get('/master/roles', async function(req, res) {
|
|
283
370
|
try {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
-- 0013_mapping_state.sql
|
|
2
|
+
-- DISABLED: shown, greyed out, not usable.
|
|
3
|
+
--
|
|
4
|
+
-- A role mapping used to say only yes (a row) or no (no row): Enabled or
|
|
5
|
+
-- Hidden. `state` on the row is the third answer. A mapped item is
|
|
6
|
+
-- enabled usable (the default: every existing row stays as it was)
|
|
7
|
+
-- disabled shown, but the API refuses it
|
|
8
|
+
-- Hidden stays what it was: no row.
|
|
9
|
+
--
|
|
10
|
+
-- Set from the Access Matrix (POST /auth/api/admin/module-state), for a role.
|
|
11
|
+
-- Workspace and user overrides are not stored here.
|
|
12
|
+
--
|
|
13
|
+
-- Idempotent: columns and constraints added only if absent, rows only if
|
|
14
|
+
-- missing.
|
|
15
|
+
|
|
16
|
+
ALTER TABLE "apisRolesMapping" ADD COLUMN IF NOT EXISTS "state" varchar(10) NOT NULL DEFAULT 'enabled';
|
|
17
|
+
ALTER TABLE "uiPagesRolesMapping" ADD COLUMN IF NOT EXISTS "state" varchar(10) NOT NULL DEFAULT 'enabled';
|
|
18
|
+
ALTER TABLE "uiElementsRolesMapping" ADD COLUMN IF NOT EXISTS "state" varchar(10) NOT NULL DEFAULT 'enabled';
|
|
19
|
+
ALTER TABLE "menuRolesMapping" ADD COLUMN IF NOT EXISTS "state" varchar(10) NOT NULL DEFAULT 'enabled';
|
|
20
|
+
|
|
21
|
+
DO $$
|
|
22
|
+
DECLARE t text;
|
|
23
|
+
BEGIN
|
|
24
|
+
FOREACH t IN ARRAY ARRAY['apisRolesMapping', 'uiPagesRolesMapping', 'uiElementsRolesMapping', 'menuRolesMapping'] LOOP
|
|
25
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = t || '_state_check') THEN
|
|
26
|
+
EXECUTE format('ALTER TABLE %I ADD CONSTRAINT %I CHECK ("state" IN (''enabled'', ''disabled''))', t, t || '_state_check');
|
|
27
|
+
END IF;
|
|
28
|
+
END LOOP;
|
|
29
|
+
END $$;
|
|
30
|
+
|
|
31
|
+
-- The routes that read and set it, with their catalog rows: reading is
|
|
32
|
+
-- access:view, setting is access:edit, like the rest of the Access Matrix.
|
|
33
|
+
INSERT INTO "apis" (id, name, "apiGroup", "isPublic", "isActive", "mtId1", "recordCreatedDate", "recordModifiedDate")
|
|
34
|
+
SELECT encode(gen_random_bytes(12), 'hex'), v.name, v.grp, false, true, '*', now(), now()
|
|
35
|
+
FROM (VALUES ('GET /auth/api/admin/module-states', 'access:view'),
|
|
36
|
+
('POST /auth/api/admin/module-state', 'access:edit')) AS v(name, grp)
|
|
37
|
+
WHERE NOT EXISTS (SELECT 1 FROM "apis" a WHERE a.name = v.name AND a."apiGroup" = v.grp);
|
|
38
|
+
|
|
39
|
+
INSERT INTO "apisRolesMapping" (id, "roleId", "apiId", "isActive", "mtId1", "recordCreatedDate", "recordModifiedDate")
|
|
40
|
+
SELECT encode(gen_random_bytes(12), 'hex'), r.id, a.id, true, '*', now(), now()
|
|
41
|
+
FROM "roles" r CROSS JOIN "apis" a
|
|
42
|
+
WHERE r.name IN ('Super Admin', 'Admin')
|
|
43
|
+
AND a.name IN ('GET /auth/api/admin/module-states', 'POST /auth/api/admin/module-state')
|
|
44
|
+
AND NOT EXISTS (SELECT 1 FROM "apisRolesMapping" m WHERE m."roleId" = r.id AND m."apiId" = a.id);
|
package/models/Api.js
CHANGED
|
@@ -39,7 +39,7 @@ class Api extends BaseModel {
|
|
|
39
39
|
modelClass: Role,
|
|
40
40
|
join: {
|
|
41
41
|
from: 'apis.id',
|
|
42
|
-
through: { from: 'apisRolesMapping.apiId', to: 'apisRolesMapping.roleId' },
|
|
42
|
+
through: { from: 'apisRolesMapping.apiId', to: 'apisRolesMapping.roleId', extra: ['state'] },
|
|
43
43
|
to: 'roles.id'
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -20,6 +20,7 @@ class ApisRolesMapping extends BaseModel {
|
|
|
20
20
|
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
21
21
|
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
22
22
|
isActive: { type: 'boolean' },
|
|
23
|
+
state: { type: 'string', enum: ['enabled', 'disabled'] },
|
|
23
24
|
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
24
25
|
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
25
26
|
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
@@ -20,6 +20,7 @@ class MenuRolesMapping extends BaseModel {
|
|
|
20
20
|
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
21
21
|
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
22
22
|
isActive: { type: 'boolean' },
|
|
23
|
+
state: { type: 'string', enum: ['enabled', 'disabled'] },
|
|
23
24
|
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
24
25
|
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
25
26
|
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
package/models/Role.js
CHANGED
|
@@ -60,7 +60,7 @@ class Role extends BaseModel {
|
|
|
60
60
|
modelClass: Api,
|
|
61
61
|
join: {
|
|
62
62
|
from: 'roles.id',
|
|
63
|
-
through: { from: 'apisRolesMapping.roleId', to: 'apisRolesMapping.apiId' },
|
|
63
|
+
through: { from: 'apisRolesMapping.roleId', to: 'apisRolesMapping.apiId', extra: ['state'] },
|
|
64
64
|
to: 'apis.id'
|
|
65
65
|
}
|
|
66
66
|
},
|
|
@@ -69,7 +69,7 @@ class Role extends BaseModel {
|
|
|
69
69
|
modelClass: UiPage,
|
|
70
70
|
join: {
|
|
71
71
|
from: 'roles.id',
|
|
72
|
-
through: { from: 'uiPagesRolesMapping.roleId', to: 'uiPagesRolesMapping.uiPageId' },
|
|
72
|
+
through: { from: 'uiPagesRolesMapping.roleId', to: 'uiPagesRolesMapping.uiPageId', extra: ['state'] },
|
|
73
73
|
to: 'uiPages.id'
|
|
74
74
|
}
|
|
75
75
|
},
|
|
@@ -78,7 +78,7 @@ class Role extends BaseModel {
|
|
|
78
78
|
modelClass: UiElement,
|
|
79
79
|
join: {
|
|
80
80
|
from: 'roles.id',
|
|
81
|
-
through: { from: 'uiElementsRolesMapping.roleId', to: 'uiElementsRolesMapping.uiElementId' },
|
|
81
|
+
through: { from: 'uiElementsRolesMapping.roleId', to: 'uiElementsRolesMapping.uiElementId', extra: ['state'] },
|
|
82
82
|
to: 'uiElements.id'
|
|
83
83
|
}
|
|
84
84
|
},
|
|
@@ -87,7 +87,7 @@ class Role extends BaseModel {
|
|
|
87
87
|
modelClass: Menu,
|
|
88
88
|
join: {
|
|
89
89
|
from: 'roles.id',
|
|
90
|
-
through: { from: 'menuRolesMapping.roleId', to: 'menuRolesMapping.menuId' },
|
|
90
|
+
through: { from: 'menuRolesMapping.roleId', to: 'menuRolesMapping.menuId', extra: ['state'] },
|
|
91
91
|
to: 'menus.id'
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -20,6 +20,7 @@ class UiElementsRolesMapping extends BaseModel {
|
|
|
20
20
|
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
21
21
|
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
22
22
|
isActive: { type: 'boolean' },
|
|
23
|
+
state: { type: 'string', enum: ['enabled', 'disabled'] },
|
|
23
24
|
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
24
25
|
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
25
26
|
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
@@ -20,6 +20,7 @@ class UiPagesRolesMapping extends BaseModel {
|
|
|
20
20
|
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
21
21
|
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
22
22
|
isActive: { type: 'boolean' },
|
|
23
|
+
state: { type: 'string', enum: ['enabled', 'disabled'] },
|
|
23
24
|
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
24
25
|
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
25
26
|
mtId3: { type: ['string', 'null'], maxLength: 25 },
|