Skip to content

Fix: Support LoginRequiredMiddleware on public Unicorn components#794

Merged
adamghill merged 4 commits intodjango-commons:mainfrom
JohananOppongAmoateng:checksum-errors
Mar 3, 2026
Merged

Fix: Support LoginRequiredMiddleware on public Unicorn components#794
adamghill merged 4 commits intodjango-commons:mainfrom
JohananOppongAmoateng:checksum-errors

Conversation

@JohananOppongAmoateng
Copy link
Contributor

Django 5.1 introduced LoginRequiredMiddleware which redirects all unauthenticated requests to the login page by
default. Because Unicorn communicates via AJAX, components on public pages would silently fail — the browser
received a 302 redirect instead of the expected JSON, causing a token/parse error. Closes #749

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/django_unicorn
  errors.py
  src/django_unicorn/components
  unicorn_view.py 267-268, 903
  src/django_unicorn/views
  __init__.py 9-12
  message.py 143
  tests/components
  test_component.py
  tests/views/message
  test_login_required.py 41, 52, 102-103, 132-133, 150-151
  utils.py
Project Total  

This report was generated by python-coverage-comment-action

Copy link
Member

@adamghill adamghill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩

@JohananOppongAmoateng
Copy link
Contributor Author

@adamghill pr rebased

@adamghill adamghill merged commit 751cfd0 into django-commons:main Mar 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Components cannot trigger model methods listening to any valid event due to the use of the LoginRequiredMiddleware middleware:

2 participants