-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat: enable dataset access for shared emails #485
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the casl facility to check if the user can update the dataset.
src/datasets/datasets.controller.ts
Outdated
// NOTE: Not sure if email is the best way to do this but since we don't have userId or something like that email is acceptable. | ||
const couldUpdateDataset = | ||
datasetToUpdate?.ownerEmail === loggedInUser.email; | ||
// $addToSet is necessary to append to the field and not overwrite | ||
// $each is necessary as data is an array of values | ||
|
||
if (!couldUpdateDataset) { | ||
throw new ForbiddenException(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to allow the update on the dataset, we should use the casl factory.
The rules is the following:
- if the user logged in belongs to the group that owns the dataset, he/she is allowed to update the dataset.
- if the user belongs to any of the admin groups, he/she can update the dataset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahaaa... I see now but do we have these rules set up already or I need to fix that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nitrosx I fixed it and now it uses casl to decide if user is able to update something or not.
Description
This PR aims to make shared datasets available for users. Also prevents all users for being able to update datasets and leave that ability only for owners.
Motivation
Anyone that has access to dataset could update or share it and people in sharedWith field were not able to access the datasets.
Fixes:
Changes:
Tests included/Docs Updated?