Repository navigation
Conversation
…ery login The login view built a fresh User(email="admin@admin.admin") and committed it on every successful password check, but User.email is declared unique, and the matching delete in logout() was never committed so the row survived session teardown. The result is that the very first login after a logout raises sqlalchemy IntegrityError on the unique index and the admin sees a 500 error page, permanently locked out of the website until the database is wiped by hand. Login now looks the admin row up by email and only inserts it when it is absent, and the uncommitted delete is dropped from logout() so that logout_user() alone ends the session; since that delete was rolled back at teardown it never removed anything, so nothing observable changes there. Dropping it also leaves current_user unused in this module, so its import goes with it. Verified with python -m py_compile on the changed file and the full test suite against a live modules server: 161 passed, 4 skipped, 5 subtests passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8
This branch has not been deployed
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.
BLUF — The website admin cannot log back in after the first logout: login 500s on a unique constraint.
website/app/account/account.pyinserts a freshUserrow with the unique emailadmin@admin.adminon every successful password check, and the matching delete inlogout()is never committed, so the second login hits the unique constraint and raisesIntegrityErrorout of the view.logout().The login view unconditionally inserts a new
Userrow on every successful password check, while the email column is unique:logout()looked like it cleaned the row up, but the delete was never committed and got rolled back at session teardown:Impact: the
admin@admin.adminrow from the first login is still there on the second login attempt. The unconditional insert then violates theemailunique constraint,IntegrityErrorpropagates out of the view, and the admin gets a 500 instead of a session — the account is effectively locked out of the web UI after the very first login/logout cycle.Fix:
login()now looks the user up by email first and only inserts when the row is absent, so re-logins reuse the existing account instead of colliding with it. The no-opdelete()inlogout()is removed (it never persisted, so removing it changes nothing observable) andlogout_user()alone ends the session; the now-unusedcurrent_userimport was dropped with it.No behaviour change beyond fixing the crash: logout still ends the session the same way it always effectively did.
Verification
website/has no automated test coverage in this repository. Verification was:python -m py_compileon the changed file — clean (website/is excluded from flake8 in CI;flake8was also run manually on the file with no output).Found during a review of the repository; other findings are being submitted as separate PRs.
🤖 Generated with Claude Code