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

Hotfix/fix admin check #39

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Hotfix/fix admin check #39

wants to merge 4 commits into from

Conversation

wow-such-code
Copy link
Member

Comment on lines +637 to +648
for (AuthorizationGroup group : searchResult.getObjects()) {
for (Person person : group.getUsers()) {
if (person.getUserId().equals(userID)) {
for (RoleAssignment r : group.getRoleAssignments()) {
if (r.getRole().equals(role) && r.getRoleLevel().equals(level)) {
return true;
}
}
}
}
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

three nested loops o.0. I find this hard to read and difficult to debug.

My suggestions:

  1. Maybe introduce some filter methods that make the code more readable
  2. Search for the groups where the users belongs to in the first place (search criteria, if API allows)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I could not fetch the groups directly via the role assignments (which should be possible according to the API), but I can certainly try to add a search subcriterium to find only groups of a specific user.

Copy link
Member Author

Choose a reason for hiding this comment

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

there does not seem to be an easy way to search for groups of a specific user. will look into this more tomorrow

@codecov
Copy link

codecov bot commented Dec 21, 2020

Codecov Report

Merging #39 (40aa0d1) into master (0c74a37) will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master     #39   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files           2       2           
  Lines         625     645   +20     
  Branches       75      81    +6     
======================================
- Misses        625     645   +20     
Impacted Files Coverage Δ
...life/qbic/openbis/openbisclient/OpenBisClient.java 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c74a37...40aa0d1. Read the comment docs.

@jenniferboedker
Copy link
Contributor

same here, what is the status of this PR? @wow-such-code @sven1103

@wow-such-code
Copy link
Member Author

Did not have time to implement this in a better way. I could ask the openBIS team if they know what the best way would be.

@KochTobi
Copy link
Member

Stale and apparently not needed.

@KochTobi KochTobi closed this Jun 13, 2023
@wow-such-code
Copy link
Member Author

I'll look into it 😅

@wow-such-code wow-such-code reopened this Jun 13, 2023
@wow-such-code wow-such-code requested a review from a team as a code owner June 13, 2023 08:53
@codecov-commenter
Copy link

Codecov Report

Patch and project coverage have no change.

Comparison is base (0c74a37) 0.00% compared to head (40aa0d1) 0.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@          Coverage Diff          @@
##            main     #39   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          2       2           
  Lines        625     645   +20     
  Branches      75      81    +6     
=====================================
- Misses       625     645   +20     
Impacted Files Coverage Δ
...life/qbic/openbis/openbisclient/OpenBisClient.java 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

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

Successfully merging this pull request may close these issues.

Check if user is instance admin in openBIS does not work for groups
5 participants