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 20:17:44 +05:30 committed by GitHub
parent 04edc3776e
commit 2ea9951175
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -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"