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

Fix valuator's permissions #80

Merged
merged 4 commits into from
Oct 25, 2023
Merged

Conversation

antopalidi
Copy link
Member

No description provided.

@antopalidi antopalidi self-assigned this Oct 10, 2023
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (b61f9b2) 91.54% compared to head (f63c906) 91.59%.

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     
Files Coverage Δ
...g_proposals/admin/proposals_controller_override.rb 87.50% <100.00%> (+0.83%) ⬆️
.../reporting_proposals/admin/permissions_override.rb 97.77% <96.87%> (-2.23%) ⬇️
...admin/valuation_assignments_controller_override.rb 87.09% <83.33%> (-2.38%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@microstudi microstudi left a 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.

Comment on lines +34 to +38
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
Copy link
Contributor

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

Comment on lines +17 to +25
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?
Copy link
Contributor

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.

@microstudi microstudi merged commit 2f26486 into main Oct 25, 2023
10 checks passed
@microstudi microstudi deleted the bugfixing/fix_valuator_permissions branch October 15, 2024 10:47
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.

2 participants