-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fix valuator's permissions #80
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #80 +/- ##
==========================================
+ Coverage 91.54% 91.59% +0.04%
==========================================
Files 78 78
Lines 1632 1677 +45
==========================================
+ Hits 1494 1536 +42
- Misses 138 141 +3
☔ View full report in Codecov by Sentry. |
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.
Thanks for this.
I think we can simplify a bit the overrides,
Also, we need to ensure we have all the spec covering the cases for the security improvement that this PR does. We can also add cases to the permissions_spec.rb if needed.
if current_user == @form.valuator_user | ||
redirect_to EngineRouter.admin_proxy(current_component).root_path | ||
else | ||
redirect_back fallback_location: EngineRouter.admin_proxy(current_component).root_path | ||
end |
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.
I understand this override is just to redirect the user to different places depending on if it is a valuator or not.
Can you explain why we need that, also we should add a test case for both cases if it is really needed
if valuator_assigned_to_proposal? | ||
can_create_proposal_note? | ||
can_create_proposal_answer? | ||
allow! if action_is_show_on_proposal? | ||
elsif action_is_show_on_proposal? | ||
disallow! | ||
end | ||
can_export_proposals? | ||
valuator_can_unassign_valuator_from_proposals? |
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.
I think we shouldn't override the whole permissions
method, is too cumbersome.
I we can just work on the override of valuator_can_unassign_valuator_from_proposals?
and put all the cases there it would be much cleaner.
No description provided.