@opengis/fastify-table 1.1.151 → 1.1.153
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,7 +1,7 @@
|
|
|
1
1
|
import { config, logger } from '../../../../utils.js';
|
|
2
2
|
import block from '../sqlInjection.js';
|
|
3
3
|
|
|
4
|
-
const {
|
|
4
|
+
const { skipCheckPolicyRoutes = [] } = config;
|
|
5
5
|
/**
|
|
6
6
|
* Middleware func
|
|
7
7
|
*
|
|
@@ -71,9 +71,6 @@ export default function checkPolicy(req, reply) {
|
|
|
71
71
|
|
|
72
72
|
/* === 0. policy: unauthorized access from admin URL === */
|
|
73
73
|
if (!user?.uid && !config.auth?.disable && isAdmin && !policy.includes('public') && !skipCheckPolicyRoutes.filter((el) => el).find(el => req.url.includes(el))) {
|
|
74
|
-
if (!req.url.startsWith(prefix) && req.url.startsWith('/api')) {
|
|
75
|
-
return reply.redirect(config?.auth?.redirect || '/login');
|
|
76
|
-
}
|
|
77
74
|
logger.file('policy/unauthorized', {
|
|
78
75
|
path, method, params, query, body, message: 'unauthorized',
|
|
79
76
|
});
|
|
@@ -26,16 +26,17 @@ export default async function filterAPI(req) {
|
|
|
26
26
|
search,
|
|
27
27
|
}) : {};
|
|
28
28
|
|
|
29
|
-
const filters = loadTable?.filters || loadTable?.filterList || [];
|
|
30
|
-
await Promise.all(filters.filter((el) => el.data).map(async (el) => {
|
|
29
|
+
const filters = loadTable?.filter_list || loadTable?.filters || loadTable?.filterList || [];
|
|
30
|
+
await Promise.all(filters.filter((el) => el.data && (el.id || el.name)).map(async (el) => {
|
|
31
|
+
const name = el.id || el.name;
|
|
31
32
|
const cls = await getSelect(el.data, pg);
|
|
32
33
|
|
|
33
34
|
if (!cls || !loadTable.table) return;
|
|
34
|
-
const { dataTypeID } = columns.find((item) => item.name ===
|
|
35
|
+
const { dataTypeID } = columns.find((item) => item.name === name) || {};
|
|
35
36
|
|
|
36
37
|
const countArr = pg.pgType[dataTypeID]?.includes('[]')
|
|
37
|
-
? await pg.queryCache(`select unnest(${
|
|
38
|
-
: await pg.queryCache(`select ${
|
|
38
|
+
? await pg.queryCache(`select unnest(${name})::text as id,count(*) from (${optimizedSQL})q group by unnest(${name})`, { table: loadTable.table, time: 5 })
|
|
39
|
+
: await pg.queryCache(`select ${name}::text as id,count(*) from (${optimizedSQL})q group by ${name}`, { table: loadTable.table, time: 5 });
|
|
39
40
|
const ids = countArr.rows.map(el1 => el1.id);
|
|
40
41
|
|
|
41
42
|
const clsData = await getSelectVal({ pg, values: ids, name: el.data });
|