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

[3260] Add feature to manage partner users for a Partner as a Organization/Bank #3266

Merged
merged 42 commits into from
Jun 19, 2024

Conversation

edwinthinks
Copy link
Collaborator

@edwinthinks edwinthinks commented Nov 23, 2022

Resolves #3260

Description

This PR adds a page to manage the users for a partner as an organization. This uses the roles!

A few additional things to change in an upcoming PR:

  • Modify the user management flow to use this code as a partner. Right now there is a Partner::UsersController which we can deprecate in favor of using common code.
  • In the update above, I would work in the ability to set the partner users as admins so they have the ability to add/remove and promote/demote users.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Tested locally. Still need to add specs.

Screenshots

See for quick recording - https://jam.dev/c/9c61fa7a-ba15-415e-8568-aabd3e4171e3

@dorner
Copy link
Collaborator

dorner commented Feb 8, 2023

@edwinthinks pushed the change - this is really just using plain old Rails forms. Everything seems to work fine. Not sure why the revoking logic doesn't work right now but this has to be rebased/merged off main anyway.

 Conflicts:
	Gemfile.lock
	app/controllers/partners_controller.rb
	app/views/partners/show.html.erb
@awwaiid
Copy link
Collaborator

awwaiid commented Feb 24, 2023

I merged in main and fixed conflicts.

@dorner dorner requested review from cielf and removed request for dorner May 24, 2024 20:43
@dorner
Copy link
Collaborator

dorner commented May 24, 2024

@cielf fixed this up, it should be good to test out!

@dorner dorner dismissed their stale review May 24, 2024 20:43

all good

@cielf
Copy link
Collaborator

cielf commented May 24, 2024

Finally! I'm not going to try to get it in for this weekend -- it's already pretty meaty -- but I will kick the tires.

cielf
cielf previously requested changes May 25, 2024
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

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

Not a complete review -- a couple of phrasing suggestions , then -- I ran into a 500 error...
How I got that:
bin/setup
bin/start
sign in as org_admin1
Partner Agencies | All Partners
choose Pawnee Parent Service
Users
In "invite user" fill in Name: User 1, email [email protected]
(that's the user with org_user status in the seed)
I got an Argument Error "nil can't be converted to a Time value" at line 45 in app/views/partner_users/_users.html.erb

It does send the email -- it's just failing on displaying?

I also want to check with the stakeholder circle on whether org_user level folk should have access to this . I know that's what it says on the issue -- but I'm not sure the question was asked.

}.to change { partner_user.roles.count }.from(1).to(0)

expect(response).to redirect_to(root_path)
expect(flash[:notice]).to eq("Access to #{partner_user.name} has been revoked.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wording change, This should be more like "#{partner_user.name}'s access has been revoked."

That form handles 99% of the cases for possessives, and may be "good enough". There is a possessive gem -- it's fairly old, but the rules don't change [I haven't looked into it in detail]

Alternatively, we could say "Access to # {partner.name} has been revoked for #{partner_user.name}"

However -- We should be using the display name in the same manner as we have in the superadmin interface (displaying the email if the name is not given) -- There are a lot of partners whose names we do not have.

@@ -34,6 +34,12 @@
<h2 class="card-title">Partner Actions</h2>
</div>
<div class="card-body p-3">
<%= link_to partner_users_path(@partner) do %>
<div class="btn btn-app bg-success">
<i class="fas fa-users"></i> Users
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please change this to "Manage Users" to follow the same form for the other actions on the page.

@cielf
Copy link
Collaborator

cielf commented Jun 5, 2024

@dorner From tonight's stakeholder meeting -- can we please limit access to this to org_admins ? Thanks.

@dorner
Copy link
Collaborator

dorner commented Jun 7, 2024

The bug you found was because you were inviting a user that already existed in the system - and that user doesn't have an invitation_sent_at. Pretty sure this is a non-case in production.

@dorner
Copy link
Collaborator

dorner commented Jun 7, 2024

Addressed other feedback!

@dorner dorner requested a review from cielf June 7, 2024 20:02
@cielf
Copy link
Collaborator

cielf commented Jun 7, 2024

The bug you found was because you were inviting a user that already existed in the system - and that user doesn't have an invitation_sent_at. Pretty sure this is a non-case in production.

Probably -- we should address that in the seed (I'm making a note for a new issue around that), and I'll test the appropriate case with a newly invited user.

@cielf cielf dismissed their stale review June 8, 2024 18:59

Looks good to me now!

@cielf cielf requested a review from awwaiid June 8, 2024 19:05
@cielf
Copy link
Collaborator

cielf commented Jun 8, 2024

@awwaiid Can you take a look -- mostly as a formality -- @dorner took this over to get it to the finish line.

cielf
cielf previously requested changes Jun 8, 2024
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

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

@dorner The manual testing looks pretty good, but it looks like you need to tweak the tests to match.

@dorner
Copy link
Collaborator

dorner commented Jun 14, 2024

@cielf fixed!

@cielf
Copy link
Collaborator

cielf commented Jun 15, 2024

The status on this is waiting for @awwaiid to take a look at it then.

@cielf cielf dismissed their stale review June 18, 2024 22:14

Tests got fixed.

@@ -129,18 +129,6 @@ def invite
end
end

def invite_partner_user
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is still referenced from config/routes.rb, but nothing submits to it, so not an immediate blocker

Copy link
Collaborator

Choose a reason for hiding this comment

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

I created #4459 to address

# frozen_String_literal: true

class PartnerUsersController < ApplicationController
before_action :set_partner, only: %i[index create destroy resend_invitation]
Copy link
Collaborator

Choose a reason for hiding this comment

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

We only link to this controller from bank admins, but we don't here restrict access to only admins. I'll open a separate ticket to address this minor security flaw.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Created #4458 to address

@awwaiid awwaiid merged commit c03df01 into main Jun 19, 2024
38 checks passed
@awwaiid awwaiid deleted the 3260/bank-partner-user-management branch June 19, 2024 15:04
Copy link
Contributor

@edwinthinks: Your PR [3260] Add feature to manage partner users for a Partner as a Organization/Bank is part of today's Human Essentials production release: 2024.06.23.
Thank you very much for your contribution!

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.

[FEAT]: As a bank user, I want to be able to manage the users for my partners
4 participants