-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
Conversation
wow-such-code
commented
Dec 21, 2020
- Fixes Check if user is instance admin in openBIS does not work for groups #38
- Fixes issue where no difference was made when determining if a user was Space or Instance Admin
- Provides convenience functions to check a user's or their user groups' role(s)
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; |
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.
three nested loops o.0. I find this hard to read and difficult to debug.
My suggestions:
- Maybe introduce some filter methods that make the code more readable
- Search for the groups where the users belongs to in the first place (search criteria, if API allows)
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.
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.
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.
there does not seem to be an easy way to search for groups of a specific user. will look into this more tomorrow
Codecov Report
@@ Coverage Diff @@
## master #39 +/- ##
======================================
Coverage 0.00% 0.00%
======================================
Files 2 2
Lines 625 645 +20
Branches 75 81 +6
======================================
- Misses 625 645 +20
Continue to review full report at Codecov.
|
same here, what is the status of this PR? @wow-such-code @sven1103 |
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. |
Stale and apparently not needed. |
I'll look into it 😅 |
Codecov ReportPatch and project coverage have no change.
❗ 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
☔ View full report in Codecov by Sentry. |