Fix error when logging out#5258
Open
nllong wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses an error encountered after logout by ensuring /account/login/ is served by SEED’s CustomLoginView (ahead of the stock two_factor URL patterns) and by removing a stale template dependency on a missing username context value.
Changes:
- Update
CustomLoginViewto provide default context values expected by the two-factor login templates. - Remove the stale hidden
usernameinput from the two-factor login template. - Add a regression test asserting the rendered login page uses the expected two-factor username field and no longer includes
name="username". - Adjust project URL routing to prioritize the custom login route.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
seed/landing/views.py |
Adds default context keys via get_context_data to avoid missing-template-context scenarios. |
seed/landing/tests.py |
Adds a regression test for the login template output. |
seed/landing/templates/two_factor/core/login.html |
Removes hidden username field that relied on missing context. |
config/urls.py |
Routes /account/login/ to CustomLoginView before including two_factor URLs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Any background context you want to provide?
When clicking logout, the system would return an error. This branch fixed the logout-to-login error caused by /account/login/ rendering the two-factor login template without the context SEED expected.
The concrete error was a Django template variable lookup issue, especially the stale {{ username }} hidden input in the login template. The added test guards against django.template DEBUG errors on GET /account/login/ and checks that the page uses the real two-factor field id="id_auth-username" instead of name="username": seed/landing/tests.py:26.
The fix also makes /account/login/ route to CustomLoginView before the stock two-factor URLs: config/urls.py:66, and supplies default context for other_devices, backup_tokens, and cancel_url: seed/landing/views.py:224.
What's this PR do?
How should this be manually tested?
What are the relevant tickets?
Screenshots (if appropriate)