[GH-ISSUE #4758] [Bug]: After you change your admin credentials, you can't keep two-factor authentication through the option. #3296

Closed
opened 2026-10-31 20:31:27 +07:00 by bsakaguchi · 2 comments
Owner

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): n
Two-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

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
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): n` Two-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 ```shell ``` ### 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 - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:31:27 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@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's flag package does not support -flag value syntax for boolean flags — it only accepts -flag (sets to true) or -flag=value. So -resetTwoFactor false is actually parsed as -resetTwoFactor=true, with the lone false becoming 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):

${xui_folder}/x-ui setting -username "${config_account}" -password "${config_password}"

Option 2 – use equals syntax:

${xui_folder}/x-ui setting -username "${config_account}" -password "${config_password}" -resetTwoFactor=false

A small PR changing line 247 of x-ui.sh would resolve this.

<!-- gh-comment-id:4591954496 --> @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's `flag` package does **not** support `-flag value` syntax for boolean flags — it only accepts `-flag` (sets to true) or `-flag=value`. So `-resetTwoFactor false` is actually parsed as `-resetTwoFactor=true`, with the lone `false` becoming 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): ```bash ${xui_folder}/x-ui setting -username "${config_account}" -password "${config_password}" ``` Option 2 – use equals syntax: ```bash ${xui_folder}/x-ui setting -username "${config_account}" -password "${config_password}" -resetTwoFactor=false ``` A small PR changing line 247 of `x-ui.sh` would resolve this.
Author
Owner

@MHSanaei commented on GitHub (Jun 1, 2026):

Fixed. Root cause: Go's flag package does not support space-separated values for boolean flags, so -resetTwoFactor false was parsed as -resetTwoFactor=true (with false becoming 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 in x-ui.sh: the preserve branch now omits the flag entirely (default is false), and the disable branch uses the explicit -resetTwoFactor=true syntax.

<!-- gh-comment-id:4596709716 --> @MHSanaei commented on GitHub (Jun 1, 2026): Fixed. Root cause: Go's `flag` package does not support space-separated values for boolean flags, so `-resetTwoFactor false` was parsed as `-resetTwoFactor=true` (with `false` becoming 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 in `x-ui.sh`: the preserve branch now omits the flag entirely (default is `false`), and the disable branch uses the explicit `-resetTwoFactor=true` syntax.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3296
No description provided.