From 18cfcce0e47a815d94a94dbbb68e30da7071524b Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Thu, 25 Jul 2024 20:48:47 +0530 Subject: [PATCH] Ensure access to `current_user` only when `self.request` exists --- recipes/DocSearch.py | 2 +- recipes/GoogleGPT.py | 2 +- recipes/VideoBots.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/DocSearch.py b/recipes/DocSearch.py index a17ec1af1..7a0d0c388 100644 --- a/recipes/DocSearch.py +++ b/recipes/DocSearch.py @@ -175,7 +175,7 @@ def run_v2( "search_query": response.final_search_query, }, ), - current_user=self.request.user, + current_user=self.request and self.request.user, ) # empty search result, abort! diff --git a/recipes/GoogleGPT.py b/recipes/GoogleGPT.py index 7f451ea13..81b09bd97 100644 --- a/recipes/GoogleGPT.py +++ b/recipes/GoogleGPT.py @@ -254,7 +254,7 @@ def run_v2( }, ), is_user_url=False, - current_user=self.request.user, + current_user=self.request and self.request.user, ) # add pretty titles to references for ref in response.references: diff --git a/recipes/VideoBots.py b/recipes/VideoBots.py index 4028f033b..d85953541 100644 --- a/recipes/VideoBots.py +++ b/recipes/VideoBots.py @@ -882,7 +882,7 @@ def run_v2( "keyword_query": response.final_keyword_query, }, ), - current_user=self.request.user, + current_user=self.request and self.request.user, ) if request.use_url_shortener: for reference in response.references: