@opengis/fastify-table 2.0.52 → 2.0.53
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.
|
@@ -82,3 +82,19 @@ else
|
|
|
82
82
|
end if;
|
|
83
83
|
|
|
84
84
|
end $$
|
|
85
|
+
|
|
86
|
+
CREATE OR REPLACE FUNCTION array_intersect(
|
|
87
|
+
anyarray,
|
|
88
|
+
anyarray)
|
|
89
|
+
RETURNS anyarray
|
|
90
|
+
LANGUAGE 'sql'
|
|
91
|
+
COST 100
|
|
92
|
+
VOLATILE PARALLEL UNSAFE
|
|
93
|
+
AS $BODY$
|
|
94
|
+
|
|
95
|
+
SELECT ARRAY(
|
|
96
|
+
SELECT UNNEST($1)
|
|
97
|
+
INTERSECT
|
|
98
|
+
SELECT UNNEST($2)
|
|
99
|
+
);
|
|
100
|
+
$BODY$;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserInfo.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/core/getUserInfo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getUserInfo.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/core/getUserInfo.ts"],"names":[],"mappings":"AAiCA,wBAA8B,WAAW,CAAC,GAAG,EAAE,GAAG,eAyDjD"}
|
|
@@ -2,6 +2,32 @@ import config from "../../../../../config.js";
|
|
|
2
2
|
import { applyHook } from "../../../../../utils.js";
|
|
3
3
|
import getRedis from "../../../../plugins/redis/funcs/getRedis.js";
|
|
4
4
|
const rclient2 = getRedis({ db: 2 });
|
|
5
|
+
const q = `select
|
|
6
|
+
|
|
7
|
+
a.route_id as id,
|
|
8
|
+
/* coalesce(d.actions, array['view', 'edit','add','del']) as role_actions,
|
|
9
|
+
coalesce(b.actions, array['view']) as interface_actions, */
|
|
10
|
+
array_intersect(coalesce(b.actions, array['view']), coalesce(d.actions, array['view', 'edit','add','del'])) as actions,
|
|
11
|
+
b.scope,
|
|
12
|
+
c.role_id,
|
|
13
|
+
c.name as role_name
|
|
14
|
+
|
|
15
|
+
from admin.routes a
|
|
16
|
+
left join admin.role_access b on
|
|
17
|
+
a.route_id=b.route_id
|
|
18
|
+
left join admin.roles c on
|
|
19
|
+
b.role_id=c.role_id
|
|
20
|
+
and c.enabled
|
|
21
|
+
left join admin.user_roles d on
|
|
22
|
+
c.role_id=d.role_id
|
|
23
|
+
and (
|
|
24
|
+
case when
|
|
25
|
+
d.expiration is not null
|
|
26
|
+
then d.expiration > CURRENT_DATE
|
|
27
|
+
else 1=1
|
|
28
|
+
end
|
|
29
|
+
)
|
|
30
|
+
where $1 in (b.user_uid, d.user_uid)`;
|
|
5
31
|
export default async function getUserInfo(req) {
|
|
6
32
|
const payload = {
|
|
7
33
|
sessionID: req.session?.sessionId,
|
|
@@ -25,12 +51,19 @@ export default async function getUserInfo(req) {
|
|
|
25
51
|
p[k1][k2] = val;
|
|
26
52
|
return p;
|
|
27
53
|
}, {});
|
|
54
|
+
const access = req.pg?.pk?.["admin.role_access"] &&
|
|
55
|
+
req.pg?.pk?.["admin.user_roles"] &&
|
|
56
|
+
req.pg?.pk?.["admin.users"] &&
|
|
57
|
+
req.user?.uid
|
|
58
|
+
? await req.pg.query(q, [req.user.uid]).then((el) => el.rows || [])
|
|
59
|
+
: [];
|
|
28
60
|
Object.assign(payload, {
|
|
29
61
|
user: userInfo,
|
|
30
62
|
settings,
|
|
31
63
|
session: !config.auth?.debug
|
|
32
64
|
? { ...req.session, passport: null }
|
|
33
65
|
: req.session,
|
|
66
|
+
access,
|
|
34
67
|
});
|
|
35
68
|
const hookData = await applyHook("afterUser", { payload });
|
|
36
69
|
return hookData || payload;
|