Skip to content

Commit

Permalink
Merge pull request #4605 from ewoknock/4596-restore_reset_password_ca…
Browse files Browse the repository at this point in the history
…pability

4596-Restore "reset password" capability -- banks to reset password for partners.
  • Loading branch information
cielf committed Aug 24, 2024
2 parents 1813bf3 + beab008 commit e9bb783
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/controllers/partner_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/views/partner_users/_users.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<i class="fa fa-envelope"></i> 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 %>
<i class="fa fa-key"></i> Reset Password
<% end %>
<%= button_to partner_user_path(partner, user), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger btn-xs" do %>
<i class="fa fa-ban"></i> Remove Access
<% end %>
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 19 additions & 0 deletions spec/requests/partner_users_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,23 @@
end
end
end

describe "POST #reset_password" do
let!(:partner_user) do
UserInviteService.invite(
email: "[email protected]",
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

0 comments on commit e9bb783

Please sign in to comment.