Create remove permission js api

This commit is contained in:
Adria Navarro 2023-08-31 10:53:25 +02:00
parent dcd8c3b289
commit 566f9ecd22
2 changed files with 20 additions and 0 deletions

View File

@ -13,6 +13,13 @@ export function createPermissionStore() {
level,
})
},
remove: async ({ level, role, resource }) => {
return await API.removePermissionFromResource({
resourceId: resource,
roleId: role,
level,
})
},
forResource: async resourceId => {
return await API.getPermissionForResource(resourceId)
},

View File

@ -21,4 +21,17 @@ export const buildPermissionsEndpoints = API => ({
url: `/api/permission/${roleId}/${resourceId}/${level}`,
})
},
/**
* Remove the the permissions for a certain resource
* @param resourceId the ID of the resource to update
* @param roleId the ID of the role to update the permissions of
* @param level the level to remove the role for this resource
* @return {Promise<*>}
*/
removePermissionFromResource: async ({ resourceId, roleId, level }) => {
return await API.delete({
url: `/api/permission/${roleId}/${resourceId}/${level}`,
})
},
})