Skip to content

fix(qr): fix 登入逾期 on get-password and blank first-open QR (#298)#304

Merged
lshw54 merged 1 commit into
codefrom
fix/issue-298-qr-otp-and-render
Jun 18, 2026
Merged

fix(qr): fix 登入逾期 on get-password and blank first-open QR (#298)#304
lshw54 merged 1 commit into
codefrom
fix/issue-298-qr-otp-and-render

Conversation

@lshw54

@lshw54 lshw54 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes two QR-login regressions reported in #298 (new 6.0.1 vs old WPF 5.9):

  1. 取得密碼 → 馬上跳登入逾期 — right after scanning + confirming a QR login, pressing "get password" immediately reports 登入逾期 and kicks the user back to login. Switching account behaves the same. Worked on 5.9.
  2. 首開 QR 跳白、掃碼問題 — on first app open the QR is blank; the only workaround is toggling region (切 HK 再切回 TW) to make the barcode show.

Fix

1. Transient 登入逾期 on get-password (src-tauri/src/commands/otp.rs)
The OTP session-expired heuristic (OtpMissingLongPollingKey / OtpMissingSecretCode, added for #264) fired on the first OTP attempt. Right after login the game-host portal session often isn't warm yet, so OTP step 1/2 come back as a login-redirect page even though the session is valid — WPF 5.9 only toasted an error and the user retried successfully, whereas the rewrite nuked the auth context on the first failure.

get_otp now, on a session-expired-looking failure, re-warms the portal session (the same auth.aspx cookie-priming GET that get_accounts runs) and retries the OTP once. Only a second session-expired failure clears auth — preserving the #264 behaviour for genuine server-side session invalidation.

2. Blank first-open QR (src/pages/QrForm.vue)
A transient cold-start network flake, or a boot navigation-storm race where the first loginQrStart is rejected by the auth store withGuard (a plain Error, deliberately swallowed), left the QR blank with no banner. QrForm now auto-retries loginQrStart once after a short delay when the first attempt produced no bitmap; the manual Refresh button stays as the user-driven fallback.

Closes #298

…open QR (#298)

Two QR-login regressions reported in #298 vs the legacy WPF 5.9 client:

1. Pressing "取得密碼" (get OTP) right after a QR login immediately
   showed "登入逾期" and forced a re-login. The OTP flow's session-
   expired heuristic (OtpMissingLongPollingKey / OtpMissingSecretCode,
   added for #264) fired on the *first* attempt — but right after login
   the game-host portal session often isn't warm yet, so step 1/2 come
   back as a login-redirect page even though the session is valid. WPF
   never nuked the session here; it just toasted an error and the user
   retried successfully.

   commands/otp.rs now re-warms the portal session (the same auth.aspx
   cookie-priming GET get_accounts performs) and retries the OTP once
   before treating the failure as a genuine expiry. Only a second
   session-expired-looking failure clears auth, preserving the #264
   behaviour for real server-side invalidation.

2. On first app open the QR area sometimes stayed blank/white with no
   error, recoverable only by toggling region (HK → TW). A transient
   cold-start network flake or a boot navigation-storm race (first
   loginQrStart rejected by the auth withGuard, a swallowed plain Error)
   left the QR empty. QrForm.vue now auto-retries loginQrStart once
   after a short delay when the first attempt yields no bitmap.

Note: symptom 1 is a reverse-engineered network protocol that can't be
exercised offline — needs live-server verification.
@lshw54 lshw54 merged commit f31fdf0 into code Jun 18, 2026
3 checks passed
@lshw54 lshw54 deleted the fix/issue-298-qr-otp-and-render branch June 18, 2026 19:03
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.

無法取得密碼

1 participant