From 8abab17e2dc0add762139c2825a643db7e28e386 Mon Sep 17 00:00:00 2001 From: Arun Kumar Date: Mon, 26 Aug 2024 01:11:21 +0530 Subject: [PATCH] fix: an error when an anonymous user fills the form (#13) * Fix an error when an anonymous user fills the form SaveDBAction.execute method uses request.user for form_user but request.user is not an instance of User for AnonymousUsers therefore we need to check for whether the user is logged in or not * Update djangocms_form_builder/actions.py Cleaner way of checking for anonymous user Co-authored-by: Fabian Braun --------- Co-authored-by: Fabian Braun --- djangocms_form_builder/actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_form_builder/actions.py b/djangocms_form_builder/actions.py index dc01b27..4058a44 100644 --- a/djangocms_form_builder/actions.py +++ b/djangocms_form_builder/actions.py @@ -119,7 +119,7 @@ def execute(self, form, request): keys = {} defaults = { "form_name": get_option(form, "form_name"), - "form_user": request.user, + "form_user": None if request.user.is_anonymous else request.user } defaults.update( {