fix(auth): hide unavailable method catalog warning

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
This commit is contained in:
XiaoSeS 2026-09-23 17:12:34 +08:00
parent c8e6988485
commit ff077bfbe7
5 changed files with 12 additions and 8 deletions

View file

@ -348,7 +348,6 @@
"organizationContinue": "Find sign-in methods",
"organizationSearching": "Searching...",
"organizationNotFound": "No organization sign-in method is available. Check your details or contact your administrator.",
"methodsUnavailable": "Sign-in methods are temporarily unavailable. Please try again.",
"externalIdentityMethods": "External identity sources",
"externalIdentityHint": "Feishu, DingTalk, GitHub, GitLab, and similar entries are advertised by the server. Account ownership is decided by backend binding and organization membership.",
"tabPassword": "Password",

View file

@ -348,7 +348,6 @@
"organizationContinue": "Найти способы входа",
"organizationSearching": "Поиск...",
"organizationNotFound": "Способ входа для организации не найден. Проверьте данные или обратитесь к администратору.",
"methodsUnavailable": "Способы входа временно недоступны. Повторите попытку позже.",
"externalIdentityMethods": "Внешние источники идентификации",
"externalIdentityHint": "Feishu, DingTalk, GitHub, GitLab и похожие входы публикуются сервером. Принадлежность аккаунта определяют привязки и членство в организациях на backend.",
"tabPassword": "Пароль",

View file

@ -348,7 +348,6 @@
"organizationContinue": "查找登录方式",
"organizationSearching": "查找中...",
"organizationNotFound": "未找到可用的组织登录方式。请核对信息,或联系组织管理员。",
"methodsUnavailable": "暂时无法获取登录方式,请稍后重试。",
"externalIdentityMethods": "外部身份源",
"externalIdentityHint": "飞书、钉钉、GitHub、GitLab 等入口由服务端配置;登录后的账号归属由后端绑定和组织关系决定。",
"tabPassword": "账号密码",

View file

@ -125,9 +125,20 @@ describe('LoginPage', () => {
render(<LoginPage />)
expect(screen.queryByRole('button', { name: 'login.tabEnterprise' })).toBeNull()
expect(screen.queryByRole('alert')).toBeNull()
expect(screen.getByLabelText('login.password').closest('[hidden]')).toBeNull()
})
it('keeps password login available without a warning when the method catalog fails', () => {
authMethodsFixture.methods = []
authMethodsFixture.isError = true
render(<LoginPage />)
expect(screen.queryByRole('alert')).toBeNull()
expect(screen.queryByRole('button', { name: 'login.tabEnterprise' })).toBeNull()
expect(screen.getByRole('button', { name: 'login.submit' })).toBeTruthy()
})
it('hides an unusable session bootstrap entry when the web runtime is not configured', () => {
authMethodsFixture.methods = [{ id: 'proxy', methodType: 'SESSION_BOOTSTRAP' }]
render(<LoginPage />)

View file

@ -31,7 +31,7 @@ export function LoginPage() {
const [loginMode, setLoginMode] = useState<'personal' | 'organization'>('personal')
const [fieldErrors, setFieldErrors] = useState<{ username?: string, password?: string }>({})
const isChinese = i18n.resolvedLanguage?.split('-')[0] === 'zh'
const { data: authMethods, isLoading: authMethodsLoading, isError: authMethodsError } = useAuthMethods(search.returnTo)
const { data: authMethods, isLoading: authMethodsLoading } = useAuthMethods(search.returnTo)
const returnTo = search.returnTo && search.returnTo.startsWith('/') ? search.returnTo : '/dashboard'
const disabledMessage = search.reason === 'accountDisabled' ? t('apiError.auth.accountDisabled') : null
@ -194,10 +194,6 @@ export function LoginPage() {
</div>
) : null}
{authMethodsError ? (
<p role="alert" className="text-sm text-destructive">{t('login.methodsUnavailable')}</p>
) : null}
{authMethodsLoading || hasExternalMethods ? (
<section className="space-y-3" aria-label={t('login.otherMethods')}>
<div className="flex items-center gap-3 text-xs text-muted-foreground before:h-px before:flex-1 before:bg-border after:h-px after:flex-1 after:bg-border">