diff --git a/app/controllers/devise/confirmations_controller.rb b/app/controllers/devise/confirmations_controller.rb index 39ff669be7..3204841fd3 100644 --- a/app/controllers/devise/confirmations_controller.rb +++ b/app/controllers/devise/confirmations_controller.rb @@ -20,6 +20,8 @@ def create # GET /resource/confirmation?confirmation_token=abcdef def show + return head :ok if request.head? + self.resource = resource_class.confirm_by_token(params[:confirmation_token]) yield resource if block_given? diff --git a/test/integration/confirmable_test.rb b/test/integration/confirmable_test.rb index f9185e87f3..cd604709a2 100644 --- a/test/integration/confirmable_test.rb +++ b/test/integration/confirmable_test.rb @@ -95,6 +95,15 @@ def resend_confirmation end end + test 'HEAD request should not confirm an account' do + user = create_user(confirm: false) + + head user_confirmation_path(confirmation_token: user.raw_confirmation_token) + + assert_response :ok + assert_not user.reload.confirmed? + end + test 'user should be redirected to a custom path after confirmation' do Devise::ConfirmationsController.any_instance.stubs(:after_confirmation_path_for).returns("/?custom=1")