Updated policies to rely on ProjectUser records #735
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's in this PR?
Closes #717, progress on #718, progress on #725
I tried to keep things simple. Due to the way the system works, we can't really have a case where a user is a project owner, but not an organization owner. We also can't really, or should not, have a case where there's a
ProjectUser
record with the role"owner"
, but the associatedproject.owner_id
is not set to the associateduser.id
.With that in mind, when checking policies:
organization.owner_id
.project.owner_id
. If that fails, then I check the associatedProjectUser
recordThis allowed me to simplify a few things.
Additionally, in all affected policies, I started removing clauses for site admin users. I don't think there's a point. We don't have an admin interface, nor do we make any other use of it. It confuses contributors and bloats the code.
When we do add an admin interface, I don't think we can even be reasonably sure we'll be using the same authorization layer. It might be easier to just make a simple one just for that interface.
Also, with the changes, I had to remove some parts of the organization membership code, but not all of it. The alternative was to spend time commenting it out, or to fix tests that are going to get removed anyway.
References
Fixes #717
Progress on: #718, #725