Skip to content

Commit

Permalink
Replace log_process_action to append_info_to_payload
Browse files Browse the repository at this point in the history
  • Loading branch information
fbbergamo committed Dec 10, 2016
1 parent 8a4d610 commit 9caae50
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/devise/controllers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ module Helpers
if respond_to?(:helper_method)
helper_method :warden, :signed_in?, :devise_controller?
end

def append_info_to_payload(payload)
super
payload[:status] ||= 401 unless payload[:exception]
end
end

module ClassMethods
Expand Down Expand Up @@ -76,11 +81,6 @@ def current_#{group_name.to_s.pluralize}
end
METHODS
end

def log_process_action(payload)
payload[:status] ||= 401 unless payload[:exception]
super
end
end

# Define authentication filters and accessor helpers based on mappings.
Expand Down
12 changes: 12 additions & 0 deletions test/integration/authenticatable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,18 @@ class AuthenticationOthersTest < Devise::IntegrationTest
refute warden.authenticated?(:user)
end
end

test 'not signed in should returns notification payload with 401 status' do
begin
subscriber = ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |_name, _start, _finish, _id, payload|
assert_equal 401, payload[:status]
end

get admins_path
ensure
ActiveSupport::Notifications.unsubscribe(subscriber)
end
end
end

class AuthenticationKeysTest < Devise::IntegrationTest
Expand Down

0 comments on commit 9caae50

Please # to comment.