Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CollectionType Creators cannot create Collections #2207

Open
bkiahstroud opened this issue May 7, 2024 · 0 comments
Open

CollectionType Creators cannot create Collections #2207

bkiahstroud opened this issue May 7, 2024 · 0 comments

Comments

@bkiahstroud
Copy link
Collaborator

Descriptive summary

I'm running Hyku v5.1.0 and I've run into an issue granting collection creation permission to a group.
I created a group to manage a Collection Type and the group has been added as Creators under the Participants tab on that collection type. I created a test user and put them in the group which causes the "Add New Collection" button to appear on the Collections dashboard as expected, but when I click the button I get directed to the home page with an error message: "You are not authorized to access this page."
- Samvera Slack

Expected behavior

If I am given Creator permissions to a CollectionType (via either direct user access or through a group), I should be able to create Collections of that type

Actual behavior

If I am given Creator permissions to a CollectionType via a group, I cannot create Collections of that type

Steps to reproduce the behavior

  1. Login as an admin
  2. Navigate to Dashboard > Manage Groups
  3. Click "Create New Group"
  4. Give the group a name and click Save
  5. Navigate to Dashboard > Settings > Collection Types
  6. Click "Create new collection type"
  7. Give the new Collection Type a name and click Save
  8. Click the "Participants" tab
  9. Under the "Add Participants" section, select the group from Step 4 and the "Creator" role
  10. Click "Add"
  11. Navigate to Dashboard > Manage Groups and edit the group from Step 4
  12. Click the "Users" tab and add a non-admin user to the group
  13. Login as the user from Step 12
  14. Navigate to Dashboard > Collections
  15. Click "Add New Collection"
  16. Observe the behavior detailed above

Related work

This was likely first introduced into Hyku with the Groups with Roles feature:

Technical details

In short, two things are required to be able to create a Collection:

  1. A Hyrax::CollectionTypeParticipant record representing the level of access the "agent" (i.e. group) has to the CollectionType
  2. A CanCanCan rule that says "this user has the ability to create Collections"

In the specific scenario detailed in this issue, the first requirement is met but the second isn't.

Code should be added the the CollectionAbility that grants the :create ability to users who have a Hyrax::CollectionTypeParticipant record.

In addition, a Hyrax::CollectionTypes::PermissionsService.can_create_collection_of_type? check should be added to Hyrax::Dashboard::CollectionsController#new to validate that the user has access to the create the specific CollectionType they are attempting to create.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant