Browse Source

fix: users getData blacklisted properties checking

Kristian Vos 2 years ago
parent
commit
4658aefb8c
1 changed files with 13 additions and 2 deletions
  1. 13 2
      backend/logic/actions/users.js

+ 13 - 2
backend/logic/actions/users.js

@@ -232,10 +232,21 @@ export default {
 
 				// If a query filter property is blacklisted throw error
 				(pipeline, next) => {
-					if (queries.filter(query => blacklistedProperties.includes(query.filter.property)).length > 0)
+					if (
+						queries.some(query =>
+							blacklistedProperties.some(blacklistedProperty =>
+								blacklistedProperty.startsWith(query.filter.property)
+							)
+						)
+					)
 						return next("Unable to filter by blacklisted property.");
-					if (Object.keys(sort).filter(property => blacklistedProperties.includes(property)).length > 0)
+					if (
+						Object.keys(sort).some(property =>
+							blacklistedProperties.some(blacklistedProperty => blacklistedProperty.startsWith(property))
+						)
+					)
 						return next("Unable to sort by blacklisted property.");
+
 					return next(null, pipeline);
 				},