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

[new_profile] Make list of available projects user dependent #9236

Merged
merged 3 commits into from
May 9, 2024

Conversation

ridz1208
Copy link
Collaborator

@ridz1208 ridz1208 commented May 5, 2024

Brief summary of changes

It seems like until this PR any user, regardless of their projects, could create participants for any other project. This is very problematic on the institutional LORIS instances like CBIG and BHI.

Currently submitted to CBIG as an override

@ridz1208 ridz1208 added Priority: Projects PR or issue is a priority for at least one project and should be a higher priority for LORIS Critical to release PR or issue is key for the release to which it has been assigned labels May 5, 2024
foreach ($projects as $projectID => $projectName) {
$projList[$projectID] = $projectName;
foreach ($user->getProjects() as $project) {
$projList[$project->getName()] = $project->getName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix the test, option 1: return "$projList[$projectID] = $projectName"
option 2: change "1" to "Pumpernickel" in modules/new_profile/test/new_profileTest.php:94

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kongtiaowang thanks, I'll check it out once I get confirmation that we are moving ahead with this

@ridz1208 ridz1208 added the Discussion Required PR or issue awaiting the resolution of a discussion between all involved parties label May 6, 2024
@ridz1208
Copy link
Collaborator Author

ridz1208 commented May 6, 2024

@driusan as you pointed out this is merely changing the front end options for projects and not preventing the actual creation of participants for other projects.

Problem is, changing the validation changes the API and I'm not 100% sure if that should be done at this stage? is it a bugfix or a change of behaviour ?

@driusan
Copy link
Collaborator

driusan commented May 6, 2024

I think there's two separate related questions:

  1. Can a user see other projects via the API?
  2. Can a user create candidates for other projects via the API?

It's debateable whether changing 1 would be a bug or a change in behaviour. Point 2, I think, is definitely a bug if it's not currently returning a 403 error.

@ridz1208
Copy link
Collaborator Author

ridz1208 commented May 6, 2024

@driusan

  1. projects GET gets all projects, not only the user's
  2. yes the API allows creation of candidates at projects that user is not affiliated with

@ridz1208
Copy link
Collaborator Author

ridz1208 commented May 9, 2024

@driusan

Loris Api Candidates
 ✘ Post candidates candid [692.80 ms]
   │
   │ Failed asserting that 403 matches expected 400.
   │
   │ /home/runner/work/Loris/Loris/raisinbread/test/api/LorisApiCandidatesTest.php:291

This test was relying on the Project instantiation to fail to return a 400 is Project='' in the JSON object. the problem is that I added my check for the project affiliation ahead of that so it returns 403 now. Is it a bad idea for me to move it below the project instantiation to catch the 400 first and then check for user affiliation?

@kongtiaowang kongtiaowang added the Passed Manual Tests PR has undergone proper testing by at least one peer label May 9, 2024
@driusan driusan merged commit cec4f99 into aces:main May 9, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical to release PR or issue is key for the release to which it has been assigned Discussion Required PR or issue awaiting the resolution of a discussion between all involved parties Passed Manual Tests PR has undergone proper testing by at least one peer Priority: Projects PR or issue is a priority for at least one project and should be a higher priority for LORIS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants