Skip to content

Instantly share code, notes, and snippets.

@u12206050
Last active October 9, 2024 18:29
Show Gist options
  • Save u12206050/56eac1d878784a93cd81f2e34d5419a7 to your computer and use it in GitHub Desktop.
Save u12206050/56eac1d878784a93cd81f2e34d5419a7 to your computer and use it in GitHub Desktop.
@julbd
Copy link

julbd commented Oct 9, 2024

@u12206050 Directus v11 removed accountability.permissions, and I don't find others way to access to permissions than permissionsService.findByQuery(...) at every request, because we cannot access stores on service side. I am missing something ?

@julbd
Copy link

julbd commented Oct 9, 2024

@u12206050 I found :

import { fetchPolicies } from '@directus/api/permissions/lib/fetch-policies';
import { fetchPermissions } from '@directus/api/permissions/lib/fetch-permissions';

(...)

const policies = await fetchPolicies(accountability, context);
const permissions = (await fetchPermissions({
	action: 'read',
	collections: [collection],
	policies,
	accountability: accountability,
}, context));
const permission = permissions?.[0];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment