Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Replace log_process_action to append_info_to_payload #4375

Merged
merged 2 commits into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 return 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