Skip to content

Commit

Permalink
Merge pull request #2503 from alphagov/fix-redirects-in-users-controller
Browse files Browse the repository at this point in the history
Fix redirects in UsersController actions: unlock_access, resend_email_change & cancel_email_change
  • Loading branch information
floehopper authored Nov 9, 2023
2 parents 3d5fe1d + 128d902 commit 7d075c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ def unlock
EventLog.record_event(@user, EventLog::MANUAL_ACCOUNT_UNLOCK, initiator: current_user, ip_address: user_ip_address)
@user.unlock_access!
flash[:notice] = "Unlocked #{@user.email}"
redirect_back_or_to(root_path)
redirect_to users_path
end

def resend_email_change
@user.resend_confirmation_instructions
if @user.errors.empty?
redirect_to root_path, notice: "Successfully resent email change email to #{@user.unconfirmed_email}"
redirect_to users_path, notice: "Successfully resent email change email to #{@user.unconfirmed_email}"
else
redirect_to edit_user_path(@user), alert: "Failed to send email change email"
end
Expand All @@ -66,7 +66,7 @@ def resend_email_change
def cancel_email_change
@user.cancel_email_change!

redirect_back_or_to(root_path)
redirect_to users_path
end

def event_logs
Expand All @@ -78,7 +78,7 @@ def reset_two_step_verification
@user.reset_2sv!(current_user)
UserMailer.two_step_reset(@user).deliver_later

redirect_to :root, notice: "Reset 2-step verification for #{@user.email}"
redirect_to users_path, notice: "Reset 2-step verification for #{@user.email}"
end

def require_2sv; end
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -814,9 +814,9 @@ class UsersControllerTest < ActionController::TestCase
assert_nil @another_user.confirmation_token
end

should "redirect to the edit user admin page" do
should "redirect to the users page" do
delete :cancel_email_change, params: { id: @another_user.id }
assert_redirected_to edit_user_path(@another_user)
assert_redirected_to users_path
end
end
end
Expand Down

0 comments on commit 7d075c7

Please sign in to comment.