Skip to content

fix: enhance login mode initialization for manual mode support - #7961

Merged
wxg0103 merged 1 commit into
v2from
pr@v2@fix_login_mode
Nov 17, 2026
Merged

wxg0103 merged 1 commit into
v2from
pr@v2@fix_login_mode

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: enhance login mode initialization for manual mode support

@wxg0103
wxg0103 merged commit 5b7b95e into v2 Nov 17, 2026
4 of 5 checks passed
@wxg0103
wxg0103 deleted the pr@v2@fix_login_mode branch November 17, 2026 02:49
changeMode('LOCAL', false)
}
})
} else {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the patch is syntactically plausible, but it introduces a few behavioral risks. Main review points:

  1. Forcing LOCAL in manual mode bypasses backend auth configuration

    if (isManual) {
      modeList.value = ['LOCAL', ...modeList.value.filter((item) => item !== 'LOCAL')]
    }

    This makes local/password login available whenever the URL contains ?login_mode=manual, even if authSetting.login_methods does not include LOCAL. If local login is disabled on the backend, the UI will offer a login method that cannot succeed. If manual mode is intended as an admin fallback, this must be explicitly supported by the backend, not only forced on the frontend. Safer:

    const methods = [...(authSetting.value?.login_methods ?? [])]
    const localSupported = methods.includes('LOCAL')
    
    if (isManual && localSupported) {
      modeList.value = ['LOCAL', ...methods.filter((item) => item !== 'LOCAL')]
    }
  2. Redundant reordering logic
    The isManual block moves LOCAL to the front, then the next block does almost the same thing again:

    if (modeList.value.includes('LOCAL')) {
      modeList.value = ['LOCAL', ...modeList.value.filter((item) => item !== 'LOCAL')]
    }

    This is redundant and can be simplified. For example:

    if (modeList.value.includes('LOCAL') || isManual) {
      modeList.value = ['LOCAL', ...modeList.value.filter((item) => item !== 'LOCAL')]
    } else if (modeList.value.includes('LDAP')) {
      ...
    }

    But only do the isManual part if local login is actually supported.

  3. New template condition is likely redundant or misleading

    v-if="item !== '' && loginMode !== item && item !== 'QR_CODE' && (item !== 'LOCAL' || loginMode !== '')"

    This hides the LOCAL button when loginMode === ''. Given loginMode is set to '' only when neither LOCAL nor LDAP is available, and manual mode now always forces LOCAL, this condition is mostly dead logic. If the intent is to hide unsupported local login, base it on whether LOCAL exists in the configured login methods, not on loginMode.

  4. Manual mode can clear modeList and then call changeMode('LOCAL')
    This block now runs in manual mode too:

    if (modeList.value.length === 1 && modeList.value[0] === 'LOCAL') {
      modeList.value = []
    }

    Then manual mode calls:

    changeMode('LOCAL', false)

    Verify that changeMode does not depend on modeList containing 'LOCAL'. If it does, this can be a bug. Either skip the clearing in manual mode, or call changeMode before clearing.

  5. showQrCodeTab behavior may change in manual mode
    Because manual mode forces LOCAL, this check will no longer set showQrCodeTab = true when QR/third-party login methods exist:

    if (!modeList.value.includes('LOCAL') && !modeList.value.includes('LDAP')) {
      showQrCodeTab.value = true
    }

    That may be intentional if manual mode should default to local login, but verify that QR login remains accessible when configured.

  6. Auth setting may be unavailable in manual mode
    If authSetting.value?.login_methods is falsy, the initialization block is skipped, but manual mode still calls:

    changeMode('LOCAL', false)

    This may set an invalid/default mode before auth settings are loaded. Add a guard or ensure authSetting is loaded before manual mode is applied.

  7. Minor style/maintainability suggestions

    • Use === instead of ==.
    • Avoid repeated authSetting.value?.login_methods; store it in a local variable.
    • Consider renaming QrList to qrList for naming consistency.
    • Reset orgOptions.value before pushing to avoid duplicates if this initialization runs more than once.
    • For Vue 3 <template v-for>, the :key is usually better placed on the <template> tag rather than the child <el-button>.

Recommended direction: keep the manual-mode fix, but make LOCAL availability depend on explicit backend support or a dedicated manual-login flag, and simplify the duplicated LOCAL reordering logic.

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.

2 participants