From 6d588e43cc5f7d5107668253323b0b0ca153169b Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 20 Aug 2018 10:58:56 +0800 Subject: [PATCH] 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 --- config/initializers/101-lograge.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/initializers/101-lograge.rb b/config/initializers/101-lograge.rb index 6e34cbe30a4..a432242ed99 100644 --- a/config/initializers/101-lograge.rb +++ b/config/initializers/101-lograge.rb @@ -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