DEV: Safe navigation to handle to nil current_user class issue (#344)

Another private plugin is extending this plugin and the current_user check here is a problem -- adding safe navigation does not break any existing functionality but allows for future changes.
This commit is contained in:
shuaib-swzd
2024-12-05 08:47:44 -06:00
committed by GitHub
parent 04edc3776e
commit 2ea9951175
@@ -147,7 +147,7 @@ module ::DiscourseDataExplorer
query_params = {}
query_params = MultiJson.load(params[:params]) if params[:params]
opts = { current_user: current_user.username }
opts = { current_user: current_user&.username }
opts[:explain] = true if params[:explain] == "true"
opts[:limit] = if params[:format] == "csv"