feat: Enhance CSRFWidget with debug logging for token session and received values

1 parent bfaba81c
...@@ -995,13 +995,18 @@ class CSRFWidget(widget.HiddenWidget): ...@@ -995,13 +995,18 @@ class CSRFWidget(widget.HiddenWidget):
if not cstruct: if not cstruct:
cstruct = new_csrf_token(request) cstruct = new_csrf_token(request)
values = self.get_template_values(field, cstruct, kw) values = self.get_template_values(field, cstruct, kw)
_logging.debug("CSRF Token session: %s", cstruct)
return field.renderer(self.template, **values) return field.renderer(self.template, **values)
def deserialize(self, field, pstruct): def deserialize(self, field, pstruct):
request = field.parent.schema.request
cstruct = get_csrf_token(request)
if pstruct is null: if pstruct is null:
return null return null
elif not isinstance(pstruct, string_types): elif not isinstance(pstruct, string_types):
raise Invalid(field.schema, "Pstruct is not a string") raise Invalid(field.schema, "Pstruct is not a string")
if not pstruct: if not pstruct:
return null return null
_logging.debug("CSRF Token received: %s", pstruct)
_logging.debug("CSRF Token session: %s", cstruct)
return pstruct return pstruct
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!