fix: add delete permissions and user the libraryId to retrieve the mapping of roles and permissions
This commit is contained in:
committed by
Adolfo R. Brandes
parent
8fd0b12f57
commit
c5cab497ac
@@ -18,6 +18,7 @@ export const libraryResourceTypes: ResourceMetadata[] = [
|
||||
|
||||
export const libraryPermissions: PermissionMetadata[] = [
|
||||
{ key: 'view_library', resource: 'library', description: 'View content, search, filter, and sort within the library.' },
|
||||
{ key: 'delete_library', resource: 'library', description: 'Allows the user to delete the library and all its contents.' },
|
||||
{ key: 'manage_library_tags', resource: 'library', description: 'Add or remove tags from content.' },
|
||||
|
||||
{ key: 'edit_library_content', resource: 'library_content', description: 'Edit content in draft mode' },
|
||||
|
||||
@@ -9,8 +9,6 @@ import { PermissionMetadata, ResourceMetadata, Role } from 'types';
|
||||
import { libraryPermissions, libraryResourceTypes, libraryRolesMetadata } from './constants';
|
||||
|
||||
const LIBRARY_TEAM_PERMISSIONS = ['view_library_team', 'manage_library_team'];
|
||||
// Note: This value can change in the future
|
||||
const LIBRARY_AUTHZ_SCOPE = '*';
|
||||
|
||||
export type AppContextType = {
|
||||
authenticatedUser: {
|
||||
@@ -51,7 +49,7 @@ export const LibraryAuthZProvider: React.FC<AuthZProviderProps> = ({ children }:
|
||||
throw new Error('NoAccess');
|
||||
}
|
||||
|
||||
const { data: libraryRoles } = usePermissionsByRole(LIBRARY_AUTHZ_SCOPE);
|
||||
const { data: libraryRoles } = usePermissionsByRole(libraryId);
|
||||
const roles = libraryRoles.map(role => ({
|
||||
...role,
|
||||
...libraryRolesMetadata.find(r => r.role === role.role),
|
||||
|
||||
Reference in New Issue
Block a user