mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4758] [Bug]: After you change your admin credentials, you can't keep two-factor authentication through the option. #3296
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3296
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ckun52880 on GitHub (Jun 1, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4758
Describe the bug
After you change your admin credentials, you can't keep two-factor authentication through the option
How to reproduce the problem
Please enter your selection [0-26]: 6
Are you sure to reset the username and password of the panel? [Default n]: y
Please set the login username [default is a random username]: xxx
Please set the login password [default is a random password]: xxx
Do you want to disable currently configured two-factor authentication? (y/n): n
Panel login username has been reset to: xxx
Panel login password has been reset to: xxx
Please use the new login username and password to access the X-UI panel. Also remember them!
Restart the panel, Attention: Restarting the panel will also restart xray [Default y]: y
[INF] x-ui and xray Restarted successfully
Expected behavior
via x-ui commands. Option 6. Reset Username & Password,
Do you want to disable currently configured two-factor authentication? (y/n): nTwo-factor authentication cannot be preserved.
Actual behavior
The 3x-ui web panel that is logging in will automatically restart, but cannot retain two-factor authentication.
Relevant logs
Screenshots
No response
3x-ui version
v3.2.5
Xray-core version
v26.6.1
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-112-generic x86_64)
Which parts of the panel are affected?
Backend (API endpoints, login, settings), Frontend (UI / panel pages), Database / migrations
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
Yes — Nginx
Before submitting
@github-actions[bot] commented on GitHub (Jun 1, 2026):
Thanks for the detailed report! This is a confirmed bug.
Root cause: In
x-ui.sh(line 247), the script passes the boolean flag as-resetTwoFactor false(space-separated). Go'sflagpackage does not support-flag valuesyntax for boolean flags — it only accepts-flag(sets to true) or-flag=value. So-resetTwoFactor falseis actually parsed as-resetTwoFactor=true, with the lonefalsebecoming an ignored trailing argument. This means 2FA is always disabled when you reset credentials, regardless of how you answer the prompt.The fix is straightforward — either omit the flag entirely when preserving 2FA (the default is already
false), or use the=syntax:Option 1 – simply omit the flag (cleanest):
Option 2 – use equals syntax:
A small PR changing line 247 of
x-ui.shwould resolve this.@MHSanaei commented on GitHub (Jun 1, 2026):
Fixed. Root cause: Go's
flagpackage does not support space-separated values for boolean flags, so-resetTwoFactor falsewas parsed as-resetTwoFactor=true(withfalsebecoming an ignored trailing argument). This wiped two-factor auth on every credential reset, regardless of the prompt answer. Verified with a standalone flag-parsing test. Fix inx-ui.sh: the preserve branch now omits the flag entirely (default isfalse), and the disable branch uses the explicit-resetTwoFactor=truesyntax.