Repository navigation
fix: enhance login mode initialization for manual mode support - #7961
Conversation
| changeMode('LOCAL', false) | ||
| } | ||
| }) | ||
| } else { |
There was a problem hiding this comment.
Overall, the patch is syntactically plausible, but it introduces a few behavioral risks. Main review points:
-
Forcing
LOCALin manual mode bypasses backend auth configurationif (isManual) { modeList.value = ['LOCAL', ...modeList.value.filter((item) => item !== 'LOCAL')] }
This makes local/password login available whenever the URL contains
?login_mode=manual, even ifauthSetting.login_methodsdoes not includeLOCAL. 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')] }
-
Redundant reordering logic
TheisManualblock movesLOCALto 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
isManualpart if local login is actually supported. -
New template condition is likely redundant or misleading
v-if="item !== '' && loginMode !== item && item !== 'QR_CODE' && (item !== 'LOCAL' || loginMode !== '')"
This hides the
LOCALbutton whenloginMode === ''. GivenloginModeis set to''only when neitherLOCALnorLDAPis available, and manual mode now always forcesLOCAL, this condition is mostly dead logic. If the intent is to hide unsupported local login, base it on whetherLOCALexists in the configured login methods, not onloginMode. -
Manual mode can clear
modeListand then callchangeMode('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
changeModedoes not depend onmodeListcontaining'LOCAL'. If it does, this can be a bug. Either skip the clearing in manual mode, or callchangeModebefore clearing. -
showQrCodeTabbehavior may change in manual mode
Because manual mode forcesLOCAL, this check will no longer setshowQrCodeTab = truewhen 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.
-
Auth setting may be unavailable in manual mode
IfauthSetting.value?.login_methodsis 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
authSettingis loaded before manual mode is applied. -
Minor style/maintainability suggestions
- Use
===instead of==. - Avoid repeated
authSetting.value?.login_methods; store it in a local variable. - Consider renaming
QrListtoqrListfor naming consistency. - Reset
orgOptions.valuebefore pushing to avoid duplicates if this initialization runs more than once. - For Vue 3
<template v-for>, the:keyis usually better placed on the<template>tag rather than the child<el-button>.
- Use
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.
fix: enhance login mode initialization for manual mode support