@opengis/admin 0.3.107 → 0.3.110

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/admin",
3
- "version": "0.3.107",
3
+ "version": "0.3.110",
4
4
  "description": "This project Softpro Admin",
5
5
  "main": "dist/admin.js",
6
6
  "type": "module",
@@ -48,7 +48,7 @@
48
48
  "@fullcalendar/vue3": "^6.1.15",
49
49
  "@opengis/fastify-auth": "1.0.86",
50
50
  "@opengis/fastify-file": "1.0.83",
51
- "@opengis/fastify-table": "^1.3.52",
51
+ "@opengis/fastify-table": "1.3.65",
52
52
  "@opengis/v3-core": "^0.3.161",
53
53
  "@opengis/v3-filter": "^0.1.3",
54
54
  "@tiptap/core": "^2.8.0",
@@ -45,7 +45,7 @@ export default async function accessGroupPost({
45
45
 
46
46
  const q = `delete from admin.user_roles where role_id='${id.replace(/'/g, "''")}';
47
47
  insert into admin.user_roles(role_id,user_uid,access_granted)
48
- values ${users.filter((el) => el?.id).map((el) => `('${id.replace(/'/g, "''")}','${el.id.replace(/'/g, "''")}','${uid?.replace(/'/g, "''")}')`)}`;
48
+ values ${users.filter((el) => el?.id).map((el) => `('${id.replace(/'/g, "''")}','${el.id.replace(/'/g, "''")}','${user?.uid?.replace(/'/g, "''")}')`)}`;
49
49
 
50
50
  await pg.query(q);
51
51
 
@@ -11,29 +11,33 @@ const components = {
11
11
  'vs-widget-comments': `select 'vs-widget-comments' as component, count(*) from crm.communications where entity_id=$1`
12
12
  };
13
13
 
14
- export default async function getCardData(req) {
14
+ export default async function getCardData(req, reply) {
15
15
 
16
16
  const {
17
- pg, params = {}, session = {}, user
17
+ pg, params = {}, session = {}, user = {},
18
18
  } = req;
19
19
  const { table, id } = params;
20
- const uid = session.passport?.user?.uid;
20
+ const { uid } = user;
21
21
 
22
22
  const res = await applyHook('cardData', { table, id, user });
23
23
  if (res) return res;
24
24
 
25
-
26
25
  const time = Date.now();
27
26
 
28
27
  const template = await getTemplate('card', table);
29
- const access = await getAccess({ table, user });
28
+ const access = await getAccess({ table, user }, pg);
29
+
30
+ if (!access?.actions?.length) {
31
+ return reply.status(403).send('access restricted');
32
+ }
30
33
 
31
34
  const tableTemplate = await getTemplate('table', table);
32
35
 
33
36
  const index = template?.find(el => el[0] === 'index.yml')?.[1] || {};
34
37
 
35
- const { message, rows = [] } = index.table && index.query ? await pg.query(`select * from ${index.table} where ${handlebarsSync.compile(index.query)({ uid, user })}`) :
36
- await getTableData({ pg, params: { table, id }, session, user });
38
+ const { message, rows = [] } = index.table && index.query
39
+ ? await pg.query(`select * from ${index.table} where ${handlebarsSync.compile(index.query)({ uid, user })}`)
40
+ : await getTableData({ pg, params: { table, id }, session, user });
37
41
 
38
42
  if (message) return { message };
39
43
 
@@ -70,14 +74,14 @@ export default async function getCardData(req) {
70
74
  .forEach(key => {
71
75
  const item = index?.tokens[key];
72
76
  Object.keys(item).filter(el => item[el]?.includes?.('{{')).forEach(el => {
73
- item[el] = handlebarsSync.compile(item[el])({ user, uid: user?.uid, id, data: rows[0] });
77
+ item[el] = handlebarsSync.compile(item[el])({ user, uid, id, data: rows[0] });
74
78
  });
75
79
 
76
80
  const token = item.form && item.table ? setToken({
77
81
  ids: [JSON.stringify(item)],
78
82
  uid,
79
83
  array: 1,
80
- })[0] : setOpt(item, user.uid);
84
+ })[0] : setOpt(item, uid);
81
85
  tokens[key] = token;
82
86
  });
83
87
  }
@@ -93,7 +97,7 @@ export default async function getCardData(req) {
93
97
  Object.assign(route, { tableTitle: tableTemplate?.title });
94
98
  if (index?.data && index?.data?.[0]?.name) {
95
99
  await Promise.all(index.data.filter((el) => el?.name && el?.sql).map(async (el) => {
96
- const q = handlebarsSync.compile(el.sql)({ data: rows[0], user, uid: user?.uid, id });
100
+ const q = handlebarsSync.compile(el.sql)({ data: rows[0], user, uid, id });
97
101
  const { rows: sqlData } = await pg.query(q);
98
102
  data[el.name] = sqlData;
99
103
  }));