Skip to content

Commit

Permalink
Merge pull request #3432 from consul/fix_exception_with_wrong_token
Browse files Browse the repository at this point in the history
Fix exception when confirming an invalid token
  • Loading branch information
javierm committed Apr 10, 2019
2 parents f801837 + 78c6395 commit bc9d66e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/users/confirmations_controller.rb
Expand Up @@ -27,7 +27,7 @@ def update
def show
# In the default implementation, this already confirms the resource:
# self.resource = self.resource = resource_class.confirm_by_token(params[:confirmation_token])
self.resource = resource_class.find_by(confirmation_token: params[:confirmation_token])
self.resource = resource_class.find_by!(confirmation_token: params[:confirmation_token])

yield resource if block_given?

Expand Down
13 changes: 13 additions & 0 deletions spec/controllers/users/confirmations_controller_spec.rb
@@ -0,0 +1,13 @@
require "rails_helper"

describe Users::ConfirmationsController do
before do
@request.env["devise.mapping"] = Devise.mappings[:user]
end

describe "GET show" do
it "returns a 404 code with a wrong token" do
expect { get :show, token: "non_existent" }.to raise_error ActiveRecord::RecordNotFound
end
end
end

0 comments on commit bc9d66e

Please sign in to comment.