3x-ui/internal/web/service/panel
sdhfsl d440c2b932
fix(panel): accept 2FA codes from adjacent TOTP windows (#6546)
* fix(panel): accept 2FA codes from adjacent TOTP windows

CheckUser compared only gotp.Now(), so a code submitted at the end of
its 30s window (or with slight client/server clock drift) failed with
'invalid 2fa code', while the immediate retry in the next window
succeeded. Accept current +/-1 window, the standard TOTP skew
tolerance.

Fixes MHSanaei/3x-ui#6535

* fix(panel): share TOTP skew tolerance with VerifyTwoFactorCode

Move the +/-1 window helper to internal/util/totp so both 2FA
acceptance points use it: login (CheckUser) and disable/rebind plus
username/password changes (VerifyTwoFactorCode). Also shrink comments
to the 2-line house rule and anchor the unit test mid-window to avoid
a step-boundary flake.

Addresses review on #6546 (MEDIUM + 2 LOWs).

---------

Co-authored-by: sdhfsl <sdhfsl@users.noreply.github.com>
2026-09-15 15:42:30 +03:00
..
api_token.go fix(cli): let -getApiToken name the token it regenerates (#6405) 2026-09-08 14:15:37 +02:00
api_token_scope_test.go feat(api): scoped, optionally expiring API tokens (#6201) 2026-08-15 15:31:49 +02:00
api_token_test.go fix(cli): let -getApiToken name the token it regenerates (#6405) 2026-09-08 14:15:37 +02:00
panel.go fix(panel): forward the panel's proxy to update.sh's own downloads (#6259) 2026-08-24 03:01:56 +02:00
panel_other.go fix: make all self-managed file downloads/installs atomic, with real completion status (#5711) 2026-07-02 18:19:33 +02:00
panel_test.go fix(panel): forward the panel's proxy to update.sh's own downloads (#6259) 2026-08-24 03:01:56 +02:00
panel_unix.go fix: make all self-managed file downloads/installs atomic, with real completion status (#5711) 2026-07-02 18:19:33 +02:00
user.go fix(panel): accept 2FA codes from adjacent TOTP windows (#6546) 2026-09-15 15:42:30 +03:00
websocket.go style: adopt golangci-lint v2 and resolve all findings 2026-06-27 15:42:22 +02:00