Repository navigation
Let abandoned anonymous sessions stop blocking re-login - #31
Merged
Merged
Conversation
TungYenTsai
force-pushed
the
fix/anon-stale-session-lock
branch
from
November 6, 2026 03:32
8ece598 to
487b914
Compare
A voter who closed the browser before finishing kept the password locked as "logged in on another device" until the session file was garbage collected, which can take hours. Treat the other session as active only while it has been used within the anonymous login idle timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
匿名投票者登入後若未完成投票就關閉瀏覽器,再次以同一密碼登入時會出現「此投票密碼已在其他裝置登入中,請先於原裝置登出後再試」,且無法繼續。
原因:
Logins::hasActiveSession()只檢查原 session 檔是否存在。匿名登入閒置逾時(anon.authTimeout,1800 秒)後,原裝置的登入已失效,但 session 檔要等 PHP GC 才刪除(session.timeout6 小時、GC 機率 1/1000),因此可能鎖住數小時以上。修改:原 session 檔最後更新時間在匿名登入閒置逾時內,才視為其他裝置登入中。已登入的投票者每次請求都會更新逾時並寫回 session 檔,所以仍在使用中的登入照常阻擋;放棄的登入在逾時後即可由新裝置登入,舊 session 會由既有的
Anon::afterLogin()清除。管理端「匿名登入狀態」的手動清除功能不變。不修改 schema、依賴、投票或計票邏輯。
驗證(dev6,PHP 8.2.35):
FormAnonConcurrentLoginTest4 tests/11 assertions 通過,新增「閒置逾時後可重新登入」及「近期活動仍阻擋」兩案;新案例在修改前的程式上失敗,確認重現問題。LoginsTest19 tests、AnonTest11 tests、AnonymityNegativeTest7 tests 通過。🤖 Generated with Claude Code