diff --git a/app/controllers/partner_users_controller.rb b/app/controllers/partner_users_controller.rb
index bb20c2f5f5..102da47f34 100644
--- a/app/controllers/partner_users_controller.rb
+++ b/app/controllers/partner_users_controller.rb
@@ -51,6 +51,13 @@ def resend_invitation
end
end
+ def reset_password
+ user = User.find(params[:id])
+
+ user.send_reset_password_instructions
+ redirect_back(fallback_location: root_path, notice: "Password e-mail sent!")
+ end
+
private
def set_partner
diff --git a/app/views/partner_users/_users.html.erb b/app/views/partner_users/_users.html.erb
index 74d7f6fb9d..7018148cdf 100644
--- a/app/views/partner_users/_users.html.erb
+++ b/app/views/partner_users/_users.html.erb
@@ -53,6 +53,9 @@
Resend Invitation
<% end %>
<% end %>
+ <%= button_to reset_password_partner_user_path(partner, user), method: :post, data: { confirm: "Are you sure?" }, class: "btn btn-info btn-xs mb-2" do %>
+ Reset Password
+ <% end %>
<%= button_to partner_user_path(partner, user), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger btn-xs" do %>
Remove Access
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index d9595315dd..a97548c5cd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -206,6 +206,7 @@ def set_up_flipper
resources :users, only: [:index, :create, :destroy], controller: 'partner_users' do
member do
post :resend_invitation
+ post :reset_password
end
end
diff --git a/spec/requests/partner_users_requests_spec.rb b/spec/requests/partner_users_requests_spec.rb
index 3fd3a5d71f..c15a59828b 100644
--- a/spec/requests/partner_users_requests_spec.rb
+++ b/spec/requests/partner_users_requests_spec.rb
@@ -111,4 +111,23 @@
end
end
end
+
+ describe "POST #reset_password" do
+ let!(:partner_user) do
+ UserInviteService.invite(
+ email: "meow@example.com",
+ name: "Meow Mix",
+ roles: [Role::PARTNER],
+ resource: partner
+ )
+ end
+
+ context "when a bank needs to reset a partner user's password" do
+ it "resends the reset password email and redirects back to root_path" do
+ expect { post reset_password_partner_user_path(default_params.merge(partner_id: partner, id: partner_user)) }.to change { ActionMailer::Base.deliveries.count }.by(1)
+ expect(response).to redirect_to(root_path)
+ expect(flash[:notice]).to eq("Password e-mail sent!")
+ end
+ end
+ end
end