diff --git a/client/src/native/appBoot.test.ts b/client/src/native/appBoot.test.ts index 73c3b0f8f..ed0a3e955 100644 --- a/client/src/native/appBoot.test.ts +++ b/client/src/native/appBoot.test.ts @@ -72,7 +72,6 @@ describe('appBoot', () => { it('FE-NATIVE-APPBOOT-004: does not wait for settings that never come, nor stop on ones that fail', async () => { vi.useFakeTimers(); - vi.spyOn(console, 'warn').mockImplementation(() => {}); const hanging = vi.fn(); void handOverToApp(new Promise(() => {}), hanging); await vi.advanceTimersByTimeAsync(1600); diff --git a/client/src/native/appBoot.ts b/client/src/native/appBoot.ts index 310bbb694..a9e17f851 100644 --- a/client/src/native/appBoot.ts +++ b/client/src/native/appBoot.ts @@ -42,10 +42,8 @@ const wait = (ms: number): Promise => new Promise((resolve) => window.setT * the app, which rises in once its first screen is there (endAppBoot). */ export function handOverToApp(settings: Promise, go: () => void): Promise { - const ready = Promise.race([settings, wait(SETTINGS_WAIT_MS)]).then( - () => undefined, - (err: unknown) => console.warn('Settings not ready for the handover:', err) - ); + // allSettled: settings that fail to load must not hold the app back either. + const ready = Promise.race([Promise.allSettled([settings]), wait(SETTINGS_WAIT_MS)]); return Promise.all([ready, wait(LEAVE_MS)]).then(() => { document.documentElement.setAttribute(HANDOVER, ''); go(); diff --git a/client/src/pages/login/AppLogin.tsx b/client/src/pages/login/AppLogin.tsx index ed58a8dc2..399ad70d8 100644 --- a/client/src/pages/login/AppLogin.tsx +++ b/client/src/pages/login/AppLogin.tsx @@ -5,9 +5,10 @@ import { useNativeServer } from '../../components/Settings/useNativeServer'; import PasswordChecklist from '../../components/shared/PasswordChecklist'; import { useTranslation } from '../../i18n'; import { lightStatusBarIcons } from '../../native/appBoot'; +import { reportNativeFailure } from '../../native/reportFailure'; import './appLogin.css'; import { heading as headingOf, oidcLoginHref, oidcOnlyHref, submitLabel, type LoginStep } from './loginModel'; -import { mfaCodeInputProps } from './MfaCodeStep'; +import { mfaCodeInputProps } from './mfaCodeInput'; import { IDP_LOGIN_URL, type useLogin } from './useLogin'; type Login = ReturnType; @@ -75,7 +76,8 @@ function AppLoginHero() { .then(({ startScenery, cameraForPlan }) => { if (!cancelled) startScenery(box, { frame: 320, camera: cameraForPlan(1), haze: false }); }) - .catch((err: unknown) => console.warn('Landscape unavailable:', err)); + // Without the landscape the box keeps its plain sea colour. + .catch(reportNativeFailure); return () => { cancelled = true; box.querySelector('canvas.scenery')?.remove(); @@ -168,7 +170,7 @@ function Credentials({ login }: { login: Login }) { const onAccount = !(login.mode === 'login' && login.mfaStep) && !login.passwordChangeStep; return ( <> -
+ void login.handleSubmit(e)}>

{heading.title}

{/* The plain sign-in needs no line under its heading; the other steps say what they ask for. */} {!heading.plain &&

{heading.subtitle}

} @@ -184,7 +186,7 @@ function Credentials({ login }: { login: Login }) { {login.mode === 'login' && onAccount && ( - )} @@ -340,40 +342,44 @@ function LoginOptions({ login }: { login: Login }) { ); } +/** Which of the ways in besides the password this server offers on this step. */ +function otherWaysOf(login: Login): { sso: boolean; passkey: boolean; demo: boolean } { + const config = login.appConfig; + const onFirstStep = login.mode === 'login' && !login.mfaStep && !login.passwordChangeStep; + return { + sso: !!(config?.oidc_configured && config.oidc_login && !login.oidcOnly), + passkey: !!(config?.passkey_login && config.passkey_configured && onFirstStep), + demo: !!config?.demo_mode, + }; +} + /** SSO, a passkey and the demo: the ways in besides the password. */ function OtherWays({ login }: { login: Login }) { const { t } = useTranslation(); - const config = login.appConfig; - const sso = !!(config?.oidc_configured && config?.oidc_login && !login.oidcOnly); - const passkey = !!( - config?.passkey_login && - config?.passkey_configured && - login.mode === 'login' && - !login.mfaStep && - !login.passwordChangeStep - ); - if (!sso && !passkey && !config?.demo_mode) return null; + const ways = otherWaysOf(login); + if (!ways.sso && !ways.passkey && !ways.demo) return null; return (
- {(sso || passkey) &&
{t('common.or')}
} - {sso && ( - {t('common.or')}
} + {ways.sso && } + {ways.passkey && ( + )} - {config?.demo_mode && ( - )} @@ -381,6 +387,20 @@ function OtherWays({ login }: { login: Login }) { ); } +function SsoButton({ login }: { login: Login }) { + const { t } = useTranslation(); + return ( + + + ); +} + function ModeSwitch({ login }: { login: Login }) { const { t } = useTranslation(); const config = login.appConfig; diff --git a/client/src/pages/login/MfaCodeStep.tsx b/client/src/pages/login/MfaCodeStep.tsx index e672028f0..0261a3a74 100644 --- a/client/src/pages/login/MfaCodeStep.tsx +++ b/client/src/pages/login/MfaCodeStep.tsx @@ -1,6 +1,7 @@ import { KeyRound } from 'lucide-react'; import React from 'react'; import { useTranslation } from '../../i18n'; +import { mfaCodeInputProps } from './mfaCodeInput'; interface MfaCodeStepProps { /** The account being signed in, kept in the form for password managers. */ @@ -11,35 +12,6 @@ interface MfaCodeStepProps { onBack: () => void; } -/** - * The one-time code field, for this step and the app's sign-in screen alike. - * Text, not numeric: backup codes carry letters. The hints are set here rather - * than left to native/keyboardFields.ts, because autoFocus gives the field - * focus before any touch could prepare it. - */ -export function mfaCodeInputProps( - code: string, - onCode: (code: string) => void, - placeholder: string -): React.InputHTMLAttributes { - return { - type: 'text', - id: 'totp', - name: 'totp', - inputMode: 'text', - autoComplete: 'one-time-code', - autoCapitalize: 'characters', - autoCorrect: 'off', - spellCheck: false, - enterKeyHint: 'go', - value: code, - onChange: (e: React.ChangeEvent) => onCode(e.target.value.toUpperCase().slice(0, 24)), - placeholder, - required: true, - autoFocus: true, - }; -} - /** The login's second step: the one-time or backup code, and the way back. */ export default function MfaCodeStep({ email, code, onCode, inputStyle, onBack }: MfaCodeStepProps) { const { t } = useTranslation(); diff --git a/client/src/pages/login/mfaCodeInput.ts b/client/src/pages/login/mfaCodeInput.ts new file mode 100644 index 000000000..db9dc7344 --- /dev/null +++ b/client/src/pages/login/mfaCodeInput.ts @@ -0,0 +1,30 @@ +import type React from 'react'; + +/** + * The one-time code field, for this step and the app's sign-in screen alike. + * Text, not numeric: backup codes carry letters. The hints are set here rather + * than left to native/keyboardFields.ts, because autoFocus gives the field + * focus before any touch could prepare it. + */ +export function mfaCodeInputProps( + code: string, + onCode: (code: string) => void, + placeholder: string +): React.InputHTMLAttributes { + return { + type: 'text', + id: 'totp', + name: 'totp', + inputMode: 'text', + autoComplete: 'one-time-code', + autoCapitalize: 'characters', + autoCorrect: 'off', + spellCheck: false, + enterKeyHint: 'go', + value: code, + onChange: (e: React.ChangeEvent) => onCode(e.target.value.toUpperCase().slice(0, 24)), + placeholder, + required: true, + autoFocus: true, + }; +} diff --git a/client/src/pages/login/useLogin.ts b/client/src/pages/login/useLogin.ts index 26f022efa..d0b6af259 100644 --- a/client/src/pages/login/useLogin.ts +++ b/client/src/pages/login/useLogin.ts @@ -170,7 +170,9 @@ export function useLogin() { // The app has no takeoff: the sign-in screen steps back and the app rises in // as soon as the settings are there (native/appBoot.ts). toastHaptic('success') - void handOverToApp(loadSettings(), () => navigate(redirectTarget)) + void handOverToApp(loadSettings(), () => { + void navigate(redirectTarget) + }) return } loadSettings()