FIX: Avoid lograge error when controller doesn't respond to `current_user`.

https://meta.discourse.org/t/broken-third-party-plugins-can-break-logging/94256
This commit is contained in:
Guo Xiang Tan 2018-08-20 10:58:56 +08:00
parent d7b1919ead
commit 6d588e43cc
1 changed files with 3 additions and 1 deletions

View File

@ -19,7 +19,9 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["
begin
username =
begin
controller.current_user&.username
if controller.respond_to?(:current_user)
controller.current_user&.username
end
rescue Discourse::InvalidAccess
nil
end