Skip to content

Ability to customize error messages #28

Closed
@simonw

Description

@simonw

The error messages this produces aren't exactly user-friendly:

asgi-csrf/asgi_csrf.py

Lines 146 to 150 in f1a7e28

await send_csrf_failed(
scope,
wrapped_send,
"form-urlencoded POST field did not match cookie",
)

asgi-csrf/asgi_csrf.py

Lines 168 to 188 in f1a7e28

await send_csrf_failed(
scope,
wrapped_send,
"multipart/form-data POST field did not match cookie",
)
return
except FileBeforeToken:
await send_csrf_failed(
scope,
wrapped_send,
"File encountered before csrftoken - make sure csrftoken is first in the HTML",
)
return
# Now replay the body
await app(scope, replay_receive, wrapped_send)
return
else:
await send_csrf_failed(
scope, wrapped_send, message="Unknown content-type"
)
return

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions