feat(flows): add flow filters
This commit is contained in:
5
packages/web/src/helpers/objectifyUrlSearchParams.js
Normal file
5
packages/web/src/helpers/objectifyUrlSearchParams.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export default function objectifyUrlSearchParams(searchParams) {
|
||||
return Array.from(searchParams.entries()).reduce((acc, [key, value]) => {
|
||||
return { ...acc, [key]: value };
|
||||
}, {});
|
||||
}
|
||||
@@ -3,17 +3,21 @@ import {
|
||||
fieldPatternMatcher,
|
||||
mongoQueryMatcher,
|
||||
} from '@casl/ability';
|
||||
// Must be kept in sync with `packages/backend/src/helpers/user-ability.ts`!
|
||||
|
||||
// Must be kept in sync with `packages/backend/src/helpers/user-ability.js`!
|
||||
export default function userAbility(user) {
|
||||
const permissions = user?.permissions;
|
||||
const role = user?.role;
|
||||
|
||||
// We're not using mongo, but our fields, conditions match
|
||||
const options = {
|
||||
conditionsMatcher: mongoQueryMatcher,
|
||||
fieldMatcher: fieldPatternMatcher,
|
||||
};
|
||||
|
||||
if (!role || !permissions) {
|
||||
return new PureAbility([], options);
|
||||
}
|
||||
|
||||
return new PureAbility(permissions, options);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user