fix(native): hide passkeys in the app through usePasskeys

The flag in useAccountSettings grew the identical destructuring in both account views past the duplication threshold; the shared passkeys hook already decides when its card is hidden, so the app check lives there now.
This commit is contained in:
Maurice
2026-10-25 18:02:45 +01:00
parent 6f3c051c7c
commit 5c37dd43c5
4 changed files with 8 additions and 13 deletions
@@ -55,7 +55,6 @@ export default function AccountTab(): React.ReactElement {
backupCodesText,
mfaRequiredByPolicy,
oidcIssuer,
passkeysAvailable,
dismissBackupCodes,
copyBackupCodes,
downloadBackupCodes,
@@ -363,8 +362,8 @@ export default function AccountTab(): React.ReactElement {
</>
</Section>
{/* Passkeys: managed in the browser, not in the native app (see useAccountSettings). */}
{passkeysAvailable && <PasskeysSection demoMode={demoMode} />}
{/* Passkeys */}
<PasskeysSection demoMode={demoMode} />
</AccountDemoLock>
{/* Delete Account Blocked */}
@@ -3,7 +3,6 @@ import React, { useEffect, useRef, useState } from 'react';
import { useNavigate, useSearchParams } from 'react-router';
import { adminApi, authApi } from '../../api/client';
import { useTranslation } from '../../i18n';
import { isNativeApp } from '../../native/platform';
import { useAuthStore } from '../../store/authStore';
import { getApiErrorMessage, type UserWithOidc } from '../../types';
import { downloadBlob } from '../../utils/fileDownload';
@@ -272,10 +271,6 @@ export function useAccountSettings({ avatarRemoveErrorKey, ignoreEmptyBackupCode
};
const oidcIssuer = (user as UserWithOidc)?.oidc_issuer;
// Passkeys stay in the browser: WebAuthn in the native app's WebView needs a
// domain association no build can have for every server, so they are managed
// there (signing in with one works through the browser hand-off too).
const passkeysAvailable = !isNativeApp();
return {
user,
@@ -308,7 +303,6 @@ export function useAccountSettings({ avatarRemoveErrorKey, ignoreEmptyBackupCode
backupCodesText,
mfaRequiredByPolicy,
oidcIssuer,
passkeysAvailable,
dismissBackupCodes,
copyBackupCodes,
downloadBackupCodes,
@@ -2,6 +2,7 @@ import { startRegistration } from '@simplewebauthn/browser';
import { useEffect, useState } from 'react';
import { authApi, type PasskeyCredential } from '../../api/client';
import { useTranslation } from '../../i18n';
import { isNativeApp } from '../../native/platform';
import { getApiErrorMessage } from '../../types';
import { useToast } from '../shared/Toast';
@@ -24,7 +25,9 @@ export function isWebauthnAbort(err: unknown): boolean {
* list, add (a password step-up, then the WebAuthn ceremony), rename, and delete
* (password step-up). Adding needs the instance toggle on AND a usable RP ID; the
* list stays reachable when the feature is later switched off so users can clean up.
* `hidden` tells a view to render nothing: in demo mode, or when there is nothing to show.
* `hidden` tells a view to render nothing: in demo mode, when there is nothing to show, or
* inside the native app, whose WebView cannot run WebAuthn for every server's domain (the
* passkeys are managed in the browser there, and signing in with one goes through it too).
*/
export function usePasskeys({ demoMode = false }: { demoMode?: boolean } = {}) {
const { t } = useTranslation();
@@ -68,7 +71,7 @@ export function usePasskeys({ demoMode = false }: { demoMode?: boolean } = {}) {
const canAdd = enabled && configured;
// Nothing to show: feature off and the user has no credentials to manage.
const nothingToShow = !loading && !enabled && creds.length === 0;
const hidden = demoMode || nothingToShow;
const hidden = demoMode || nothingToShow || isNativeApp();
// The toggle is on but no usable RP ID resolves, so adding stays off.
const notConfigured = enabled && !configured;
@@ -61,7 +61,6 @@ export default function MSettingsAccount() {
backupCodesText,
mfaRequiredByPolicy,
oidcIssuer,
passkeysAvailable,
dismissBackupCodes,
copyBackupCodes,
downloadBackupCodes,
@@ -291,7 +290,7 @@ export default function MSettingsAccount() {
</>
</MSetCard>
{passkeysAvailable && <MPasskeysCard demoMode={demoMode} />}
<MPasskeysCard demoMode={demoMode} />
</AccountDemoLock>
<MConfirmSheet