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

Restrict ability on clients with archived intakes on hub client related actions #5491

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

Conversation

embarnard
Copy link
Contributor

@embarnard embarnard commented Jan 30, 2025

Link to pivotal/JIRA issue

Is PM acceptance required? (delete one)

  • Yes - don't merge until JIRA issue is accepted!

Reminder: merge main into this branch and get green tests before merging to main

What was done?

Restrict ability of hub users non-admins from making changes to clients with archived intakes including:

  • add/edit/delete a tax return for a previous year
  • add notes
  • add documents

There was also some general clean up of the ability and client controller file including:

  • replaced broken renderings of public_pages/page_not_found with 403 page
  • new methods for seeing if client has archived intake
  • add new 13614c_form pages to ability authorization checks
  • client actions in ability files are split between reads which can happen for any client in the accessible group and other actions that should only happen on present year intakes
  • Added a lot of tests to make sure an access denied error is raised if user is trying to hit an action on an archived intake

How to test?

  • Try to take any of the following actions on GYR clients with an archived intake:
  • :flag, :toggle_field, :edit_take_action, :update_take_action, :edit_13614c_form_page1, :edit_13614c_form_page2, :edit_13614c_form_page3, :edit_13614c_form_page4, :edit_13614c_form_page5, :update_13614c_form_page1, :update_13614c_form_page2, :update_13614c_form_page3, :update_13614c_form_page4, :update_13614c_form_page5, :cancel_13614c, :save_and_maybe_exit, unlock
  • also any actions on notes, documents or tax returns besides read
  • each action on the bulk action page like change org, assignees and send message

Screenshots (for visual changes)

fixed random overlapping buttons, everything else visually should be the same

  • Before
Screenshot 2025-01-30 at 1 32 30 PM
  • After
Screenshot 2025-01-30 at 1 32 46 PM

Copy link

Heroku app: https://gyr-review-app-5491-7545bb5f1cb5.herokuapp.com/
View logs: heroku logs --app gyr-review-app-5491 (optionally add --tail)

@@ -47,8 +43,6 @@ def destroy
end

def edit
return render "public_pages/page_not_found", status: 404 if @client.intake.is_ctc?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this "public_pages/page_not_found" does not actually exist in the hub so this page is right now showing up blank, "raise CanCan::AccessDenied" will show the Access Denied page

@@ -105,8 +99,6 @@ def update_take_action
end

def unlock
raise CanCan::AccessDenied unless current_user.admin? || current_user.org_lead? || current_user.site_coordinator?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is now specified in ability.rb, functionality is the same with the addition that they will also see this page if client has archived intake

@@ -4,7 +4,7 @@ class CtcClientsController < Hub::BaseController
layout "hub"

def edit
return render "public_pages/page_not_found", status: 404 unless @client.intake.is_ctc?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above this page doesn't exist for the hub

@@ -1,7 +1,7 @@
module Hub
class NotesController < Hub::BaseController
load_and_authorize_resource :client
load_and_authorize_resource through: :client, only: [:create]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we want it to authorize on all the actions

@@ -53,7 +53,7 @@
<%= f.hidden_field(:role, value: params[:role]) %>

<div>
<%= f.submit t(".submit"), class: "button button--primary" %>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

buttons were overlapping

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-01-30 at 1 32 30 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After:
Screenshot 2025-01-30 at 1 32 46 PM

can :manage, TaxReturnSelection, tax_returns: { client: { vita_partner: accessible_groups } }
cannot :manage, TaxReturnSelection, tax_returns: { client: { vita_partner: VitaPartner.where.not(id: accessible_groups) }}
can :manage, TaxReturnSelection, tax_returns: { client: { vita_partner: accessible_groups, intake: { product_year: Rails.configuration.product_year } } }
cannot :manage, TaxReturnSelection, tax_returns: { client: { vita_partner: VitaPartner.where.not(id: accessible_groups) } }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

technically i don't think we need this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

never mind i removed it and it caused issues

client_role_whitelist = [
:client_success, :admin, :org_lead, :site_coordinator,
:coalition_lead, :state_file_admin, :team_member
].freeze

if user.role?(client_role_whitelist)
can :manage, Client, vita_partner: accessible_groups
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept existing functionality that admins can manage everything for the Client. In the future, since the client management actions are now broken out for client_role_whitelist users and not a blanket :manage action, we'll have to remember to explicitly allow them for non-admins if needed. Not sure we should explicitly state each client action permission for admins too as a guardrail for pushing up work that needs to touch this ability file?

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -12,11 +12,7 @@ class ClientsController < Hub::BaseController
before_action :redirect_unless_client_is_hub_status_editable, only: [:edit, :edit_take_action, :update, :update_take_action]
layout "hub"

MAX_COUNT = 1000
Copy link
Contributor Author

Choose a reason for hiding this comment

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

used to be used for pagination, now not getting used anything

@embarnard embarnard changed the title Wip: client, notes and documents ability Restrict ability on client, notes and documents in hub for clients with archived intakes Feb 11, 2025
@embarnard embarnard marked this pull request as ready for review February 11, 2025 18:52
@embarnard embarnard changed the title Restrict ability on client, notes and documents in hub for clients with archived intakes Restrict ability on clients with archived intakes on hub client related actions Feb 11, 2025
:update_13614c_form_page1, :update_13614c_form_page2,
:update_13614c_form_page3, :cancel_13614c,
:resource_to_client_redirect,
Copy link
Contributor

Choose a reason for hiding this comment

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

just asking for my own curiosity: what was :resource_to_client_redirect originally for/doing? (i'm seeing that it got removed here.)

Copy link
Contributor

@spompea-cfa spompea-cfa left a comment

Choose a reason for hiding this comment

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

approved 🌟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants