Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(app): show sign-in settings by account setup state

Hampusb64bae646aec
diff --git a/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountSecurityCard.tsx b/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountSecurityCard.tsx
index 62f41aecd..7aac0a309 100644
--- a/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountSecurityCard.tsx
+++ b/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountSecurityCard.tsx
@@ -1,18 +1,14 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
-import statusStyles from '@app/features/app/components/dialogs/components/plutonium/PurchaseHistoryStatus.module.css';
import styles from '@app/features/user/components/modals/tabs/account_security_tab/AccountSecurityCard.module.css';
import {clsx} from 'clsx';
import type React from 'react';
import {useId} from 'react';
-type AccountSecurityStatusTone = 'success' | 'muted' | 'neutral' | 'pending';
-
interface AccountSecurityCardProps {
title?: React.ReactNode;
'aria-label'?: string;
description?: React.ReactNode;
- status?: {label: React.ReactNode; tone: AccountSecurityStatusTone};
action?: React.ReactNode;
children?: React.ReactNode;
'data-flx'?: string;
@@ -21,7 +17,6 @@ interface AccountSecurityCardProps {
export const AccountSecurityCard: React.FC<AccountSecurityCardProps> = ({
title,
description,
- status,
action,
children,
'aria-label': ariaLabel,
@@ -44,11 +39,6 @@ export const AccountSecurityCard: React.FC<AccountSecurityCardProps> = ({
{title}
</h4>
) : null}
- {status ? (
- <span className={statusStyles[status.tone]} data-flx="user.account-security-card.status">
- {status.label}
- </span>
- ) : null}
</div>
{description ? (
<p className={styles.description} data-flx="user.account-security-card.description">
diff --git a/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountSecuritySections.tsx b/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountSecuritySections.tsx
index ee7cd2c6e..cd98fdc72 100644
--- a/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountSecuritySections.tsx
+++ b/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountSecuritySections.tsx
@@ -81,39 +81,33 @@ export const AccountSecuritySections: React.FC<AccountSecuritySectionsProps> = o
};
return (
<>
- {isClaimed && (
- <SettingsSection
- id="account"
- title={i18n._(SIGN_IN_DETAILS_DESCRIPTOR)}
- data-flx="user.account-security-sections.account"
- >
- <AccountTabContent
- user={user}
- isClaimed={isClaimed}
- showMaskedEmail={showMaskedEmail}
- setShowMaskedEmail={setShowMaskedEmail}
- data-flx="user.account-security-sections.account-tab-content"
- />
- </SettingsSection>
- )}
- {isClaimed && (
- <SettingsSection
- id="security"
- title={i18n._(SECURITY_DESCRIPTOR)}
- defaultExpanded={targetSection === 'security'}
- data-flx="user.account-security-sections.security"
- >
- <SecurityTabContent
- user={user}
- isClaimed={isClaimed}
- passkeys={passkeys}
- authorizedAppsSubmitting={authorizedAppsSubmitting}
- onManageAuthorizedApps={openAuthorizedAppsModal}
- onManageLinkedDevices={openLinkedDevicesModal}
- data-flx="user.account-security-sections.security-tab-content"
- />
- </SettingsSection>
- )}
+ <SettingsSection
+ id="account"
+ title={i18n._(SIGN_IN_DETAILS_DESCRIPTOR)}
+ data-flx="user.account-security-sections.account"
+ >
+ <AccountTabContent
+ user={user}
+ showMaskedEmail={showMaskedEmail}
+ setShowMaskedEmail={setShowMaskedEmail}
+ data-flx="user.account-security-sections.account-tab-content"
+ />
+ </SettingsSection>
+ <SettingsSection
+ id="security"
+ title={i18n._(SECURITY_DESCRIPTOR)}
+ defaultExpanded={targetSection === 'security'}
+ data-flx="user.account-security-sections.security"
+ >
+ <SecurityTabContent
+ user={user}
+ passkeys={passkeys}
+ authorizedAppsSubmitting={authorizedAppsSubmitting}
+ onManageAuthorizedApps={openAuthorizedAppsModal}
+ onManageLinkedDevices={openLinkedDevicesModal}
+ data-flx="user.account-security-sections.security-tab-content"
+ />
+ </SettingsSection>
<SettingsSection
id="danger_zone"
title={i18n._(DANGER_ZONE_DESCRIPTOR)}
diff --git a/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountTab.tsx b/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountTab.tsx
index 6c5a2d659..edf68d2bf 100644
--- a/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountTab.tsx
+++ b/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/AccountTab.tsx
@@ -4,7 +4,6 @@ import {EmailVerificationAlert} from '@app/features/app/components/dialogs/compo
import {UnclaimedAccountAlert} from '@app/features/app/components/dialogs/components/UnclaimedAccountAlert';
import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
import {openClaimAccountModal} from '@app/features/auth/components/modals/ClaimAccountModal';
-import {canResendVerificationEmail} from '@app/features/auth/hooks/useVerifyEmailAction';
import {Button} from '@app/features/ui/button/Button';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
import {modal} from '@app/features/ui/commands/ModalCommands';
@@ -20,11 +19,13 @@ import {
RecoveryKitRow,
} from '@app/features/user/components/modals/tabs/account_security_tab/RecoveryKitSettings';
import type {User} from '@app/features/user/models/User';
+import {needsEmailConfirmation} from '@app/features/user/utils/AccountGates';
import * as DateUtils from '@app/features/user/utils/DateFormatting';
import {
HIDE_EMAIL_TOGGLE_DESCRIPTOR,
REVEAL_DESCRIPTOR as REVEAL_EMAIL_TOGGLE_DESCRIPTOR,
} from '@app/features/user/utils/UserMessageDescriptors';
+import {AccountTiers, AccountVerificationNeeds} from '@fluxer/constants/src/AccountTierConstants';
import {msg} from '@lingui/core/macro';
import {Trans, useLingui} from '@lingui/react/macro';
import {observer} from 'mobx-react-lite';
@@ -42,16 +43,22 @@ const maskEmail = (email: string): string => {
interface AccountTabProps {
user: User;
- isClaimed: boolean;
showMaskedEmail: boolean;
setShowMaskedEmail: (show: boolean) => void;
}
-export const AccountTabContent: React.FC<AccountTabProps> = observer(
- ({user, isClaimed, showMaskedEmail, setShowMaskedEmail}) => {
- const {i18n} = useLingui();
- const usesUsernameSignIn = RuntimeConfig.usesUsernameSignIn;
- const emailRow = usesUsernameSignIn ? null : isClaimed ? (
+export const AccountTabContent: React.FC<AccountTabProps> = observer(({user, showMaskedEmail, setShowMaskedEmail}) => {
+ const {i18n} = useLingui();
+ const usesUsernameSignIn = RuntimeConfig.usesUsernameSignIn;
+ const need = user.verificationNeed;
+ const needsPassword = need === AccountVerificationNeeds.SET_PASSWORD;
+ const isClaimed = user.accountTier !== AccountTiers.UNCLAIMED;
+ const email = user.email;
+ let emailRow: React.ReactNode;
+ if (usesUsernameSignIn) {
+ emailRow = null;
+ } else if (email != null) {
+ emailRow = (
<AccountSecurityRow
label={<Trans>Email address</Trans>}
description={
@@ -63,7 +70,7 @@ export const AccountTabContent: React.FC<AccountTabProps> = observer(
className={`${styles.emailText} ${showMaskedEmail ? styles.emailTextSelectable : ''}`}
data-flx="user.account-security-tab.account-tab.account-tab-content.email-text"
>
- {showMaskedEmail ? user.email : maskEmail(user.email!)}
+ {showMaskedEmail ? email : maskEmail(email)}
</span>
<button
type="button"
@@ -77,7 +84,7 @@ export const AccountTabContent: React.FC<AccountTabProps> = observer(
}
data-flx="user.account-security-tab.account-tab.account-tab-content.email-row"
>
- {RuntimeConfig.emailsEnabled && (
+ {RuntimeConfig.emailsEnabled && isClaimed && (
<Button
variant="secondary"
small={true}
@@ -97,22 +104,82 @@ export const AccountTabContent: React.FC<AccountTabProps> = observer(
</Button>
)}
</AccountSecurityRow>
- ) : (
+ );
+ } else {
+ emailRow = (
<AccountSecurityRow
label={<Trans>Email address</Trans>}
warning={<Trans>No email address set</Trans>}
data-flx="user.account-security-tab.account-tab.account-tab-content.email-row--unclaimed"
+ >
+ {!isClaimed && (
+ <Button
+ small={true}
+ onClick={() => openClaimAccountModal()}
+ data-flx="user.account-security-tab.account-tab.account-tab-content.button.add-email"
+ >
+ <Trans>Add email</Trans>
+ </Button>
+ )}
+ </AccountSecurityRow>
+ );
+ }
+ let passwordRow: React.ReactNode;
+ if (need === AccountVerificationNeeds.ADD_EMAIL) {
+ passwordRow = null;
+ } else if (needsPassword) {
+ passwordRow = (
+ <AccountSecurityRow
+ label={<Trans>Password</Trans>}
+ warning={<Trans>No password set</Trans>}
+ data-flx="user.account-security-tab.account-tab.account-tab-content.password-row--unclaimed"
>
<Button
small={true}
onClick={() => openClaimAccountModal()}
- data-flx="user.account-security-tab.account-tab.account-tab-content.button.add-email"
+ data-flx="user.account-security-tab.account-tab.account-tab-content.button.set-password"
>
- <Trans>Add email</Trans>
+ <Trans>Set password</Trans>
</Button>
</AccountSecurityRow>
);
- const passwordRow = isClaimed ? (
+ } else if (!user.hasPassword && RuntimeConfig.emailsEnabled) {
+ passwordRow = (
+ <AccountSecurityRow
+ label={<Trans>Password</Trans>}
+ description={
+ user.accountTier === AccountTiers.VERIFIED ? (
+ <Trans comment="Description of the password row in account settings when the account has a confirmed email but no password.">
+ You sign in with a code sent to your email. A password is optional.
+ </Trans>
+ ) : (
+ <Trans comment="Description of the password row in account settings when the account email is not confirmed yet.">
+ Confirm your email first. Then you can set a password.
+ </Trans>
+ )
+ }
+ data-flx="user.account-security-tab.account-tab.account-tab-content.password-row--set"
+ >
+ {user.accountTier === AccountTiers.VERIFIED && (
+ <Button
+ variant="secondary"
+ small={true}
+ onClick={() =>
+ ModalCommands.push(
+ modal(() => (
+ <PasswordChangeModal data-flx="user.account-security-tab.account-tab.account-tab-content.password-set-modal" />
+ )),
+ )
+ }
+ data-flx="user.account-security-tab.account-tab.account-tab-content.button.set-password--claimed"
+ >
+ <Trans>Set password</Trans>
+ </Button>
+ )}
+ </AccountSecurityRow>
+ );
+ } else {
+ passwordRow = (
<AccountSecurityRow
label={<Trans>Password</Trans>}
description={
@@ -139,49 +206,35 @@ export const AccountTabContent: React.FC<AccountTabProps> = observer(
<Trans>Change password</Trans>
</Button>
</AccountSecurityRow>
- ) : (
- <AccountSecurityRow
- label={<Trans>Password</Trans>}
- warning={<Trans>No password set</Trans>}
- data-flx="user.account-security-tab.account-tab.account-tab-content.password-row--unclaimed"
- >
- <Button
- small={true}
- onClick={() => openClaimAccountModal()}
- data-flx="user.account-security-tab.account-tab.account-tab-content.button.set-password"
- >
- <Trans>Set password</Trans>
- </Button>
- </AccountSecurityRow>
);
- return (
- <>
- {!isClaimed && (
- <UnclaimedAccountAlert data-flx="user.account-security-tab.account-tab.account-tab-content.unclaimed-account-alert" />
- )}
+ }
+ return (
+ <>
+ {needsPassword && (
+ <UnclaimedAccountAlert data-flx="user.account-security-tab.account-tab.account-tab-content.unclaimed-account-alert" />
+ )}
+ {usesUsernameSignIn && isClaimed && (
+ <RecoveryKitReminderAlert
+ user={user}
+ data-flx="user.account-security-tab.account-tab.account-tab-content.recovery-kit-reminder-alert"
+ />
+ )}
+ <AccountSecurityCard
+ aria-label={i18n._(SIGN_IN_METHODS_DESCRIPTOR)}
+ data-flx="user.account-security-tab.account-tab.account-tab-content.rows"
+ >
+ {emailRow}
+ {passwordRow}
{usesUsernameSignIn && isClaimed && (
- <RecoveryKitReminderAlert
+ <RecoveryKitRow
user={user}
- data-flx="user.account-security-tab.account-tab.account-tab-content.recovery-kit-reminder-alert"
+ data-flx="user.account-security-tab.account-tab.account-tab-content.recovery-kit-row"
/>
)}
- <AccountSecurityCard
- aria-label={i18n._(SIGN_IN_METHODS_DESCRIPTOR)}
- data-flx="user.account-security-tab.account-tab.account-tab-content.rows"
- >
- {emailRow}
- {passwordRow}
- {usesUsernameSignIn && isClaimed && (
- <RecoveryKitRow
- user={user}
- data-flx="user.account-security-tab.account-tab.account-tab-content.recovery-kit-row"
- />
- )}
- </AccountSecurityCard>
- {canResendVerificationEmail(user) && (
- <EmailVerificationAlert data-flx="user.account-security-tab.account-tab.account-tab-content.email-verification-alert" />
- )}
- </>
- );
- },
-);
+ </AccountSecurityCard>
+ {needsEmailConfirmation(user) && (
+ <EmailVerificationAlert data-flx="user.account-security-tab.account-tab.account-tab-content.email-verification-alert" />
+ )}
+ </>
+ );
+});
diff --git a/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/SecurityTab.tsx b/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/SecurityTab.tsx
index 9a7eabbd8..ee2f4a527 100644
--- a/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/SecurityTab.tsx
+++ b/fluxer_app/src/features/user/components/modals/tabs/account_security_tab/SecurityTab.tsx
@@ -1,18 +1,15 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {ConfirmModal} from '@app/features/app/components/dialogs/ConfirmModal';
+import {VerifyEmailButton} from '@app/features/app/components/dialogs/components/EmailVerificationAlert';
import {SettingsTabSection} from '@app/features/app/components/dialogs/shared/SettingsTabLayout';
import {BackupCodesModal} from '@app/features/auth/components/modals/BackupCodesModal';
import {BackupCodesViewModal} from '@app/features/auth/components/modals/BackupCodesViewModal';
-import {openClaimAccountModal} from '@app/features/auth/components/modals/ClaimAccountModal';
import {MfaTotpDisableModal} from '@app/features/auth/components/modals/MfaTotpDisableModal';
import {MfaTotpEnableModal} from '@app/features/auth/components/modals/MfaTotpEnableModal';
import {PasskeyNameModal} from '@app/features/auth/components/modals/PasskeyNameModal';
-import * as WebAuthnUtils from '@app/features/auth/utils/WebAuthnUtils';
-import {
- CLAIM_ACCOUNT_DESCRIPTOR,
- TWO_FACTOR_AUTHENTICATION_DESCRIPTOR,
-} from '@app/features/i18n/utils/CommonMessageDescriptors';
+import {startPasskeyRegistration} from '@app/features/auth/utils/PasskeyRegistrationFlow';
+import {TWO_FACTOR_AUTHENTICATION_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
import {Logger} from '@app/features/platform/utils/AppLogger';
import {Button} from '@app/features/ui/button/Button';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
@@ -32,8 +29,11 @@ import {
} from '@app/features/user/components/settings_utils/section_registry/SharedDescriptors';
import type {User} from '@app/features/user/models/User';
import type {WebAuthnCredential} from '@app/features/user/state/WebAuthnCredentials';
+import {getAccountGatePresentation} from '@app/features/user/utils/AccountGatePresentation';
+import {canPerform} from '@app/features/user/utils/AccountGates';
import * as DateUtils from '@app/features/user/utils/DateFormatting';
import {pushApiErrorModal} from '@app/lib/forms';
+import {AccountVerificationNeeds, TierGatedActions} from '@fluxer/constants/src/AccountTierConstants';
import {UserAuthenticatorTypes} from '@fluxer/constants/src/UserConstants';
import {msg} from '@lingui/core/macro';
import {Trans, useLingui} from '@lingui/react/macro';
@@ -49,15 +49,6 @@ const COULD_NOT_DELETE_PASSKEY_DESCRIPTOR = msg({
message: "Couldn't delete passkey",
comment: 'Title of the error modal shown when removing a registered passkey fails.',
});
-const VERIFY_EMAIL_BEFORE_AUTHENTICATOR_APP_DESCRIPTOR = msg({
- message: 'Verify your email before adding an authenticator app.',
- comment:
- 'Security settings warning shown when an unverified account cannot enable authenticator-app two-factor authentication.',
-});
-const VERIFY_EMAIL_BEFORE_PASSKEY_DESCRIPTOR = msg({
- message: 'Verify your email before adding a passkey.',
- comment: 'Security settings warning shown when an unverified account cannot register a new passkey.',
-});
const PASSKEY_TWO_FACTOR_ENABLE_TITLE_DESCRIPTOR = msg({
message: 'Use passkeys for two-factor authentication?',
comment: 'Security settings: confirmation modal title for turning on passkey-based two-factor authentication.',
@@ -103,20 +94,6 @@ const TWO_FACTOR_CARD_DESCRIPTION_DESCRIPTOR = msg({
message: 'Ask for a second step after your password when you sign in.',
comment: 'Security settings: description under the two-factor authentication card title.',
});
-const STATUS_ON_DESCRIPTOR = msg({
- message: 'On',
- comment:
- 'Security settings: status badge next to the two-factor authentication title when it is turned on. One word.',
-});
-const STATUS_OFF_DESCRIPTOR = msg({
- message: 'Off',
- comment:
- 'Security settings: status badge next to the two-factor authentication title when it is turned off. One word.',
-});
-const PASSKEY_COUNT_DESCRIPTOR = msg({
- message: '{count, plural, one {# passkey} other {# passkeys}}',
- comment: 'Security settings: badge next to the Passkeys title showing how many passkeys are registered.',
-});
const TURN_OFF_AUTHENTICATOR_APP_DESCRIPTOR = msg({
message: 'Turn off authenticator app',
comment:
@@ -160,7 +137,6 @@ const logger = new Logger('SecurityTab');
interface SecurityTabProps {
user: User;
- isClaimed: boolean;
passkeys: ReadonlyArray<WebAuthnCredential>;
authorizedAppsSubmitting?: boolean;
onManageAuthorizedApps?: () => void;
@@ -168,37 +144,21 @@ interface SecurityTabProps {
}
export const SecurityTabContent: React.FC<SecurityTabProps> = observer(
- ({user, isClaimed, passkeys, authorizedAppsSubmitting, onManageAuthorizedApps, onManageLinkedDevices}) => {
+ ({user, passkeys, authorizedAppsSubmitting, onManageAuthorizedApps, onManageLinkedDevices}) => {
const {i18n} = useLingui();
const hasTotpMfa = user.authenticatorTypes?.includes(UserAuthenticatorTypes.TOTP) ?? false;
const hasPasskeyMfa = user.authenticatorTypes?.includes(UserAuthenticatorTypes.WEBAUTHN) ?? false;
const hasAnyMfa = hasTotpMfa || hasPasskeyMfa;
- const needsEmailVerification = user.email != null && user.verified === false;
+ const mfaGate = canPerform(user, TierGatedActions.MFA);
+ const needsEmailVerification = !mfaGate.allowed && mfaGate.need === AccountVerificationNeeds.CONFIRM_EMAIL;
const hasReachedPasskeyLimit = passkeys.length >= 10;
const canAddSecurityCredential = !needsEmailVerification;
const canAddPasskey = canAddSecurityCredential && !hasReachedPasskeyLimit;
- const registerPasskey = async (name: string) => {
- try {
- const options = await UserCommands.getWebAuthnRegistrationOptions();
- const credential = await WebAuthnUtils.performRegistration(options);
- await UserCommands.registerWebAuthnCredential(credential, options.challenge, name);
- } catch (error) {
- logger.error('Failed to add passkey', error);
- throw error;
- }
- };
const handleAddPasskey = () => {
if (!canAddPasskey) {
return;
}
- ModalCommands.push(
- modal(() => (
- <PasskeyNameModal
- onSubmit={registerPasskey}
- data-flx="user.account-security-tab.security-tab.handle-add-passkey.passkey-name-modal"
- />
- )),
- );
+ void startPasskeyRegistration(i18n);
};
const handleRenamePasskey = async (credentialId: string) => {
ModalCommands.push(
@@ -239,26 +199,31 @@ export const SecurityTabContent: React.FC<SecurityTabProps> = observer(
};
const handleTogglePasskeyTwoFactor = (enabled: boolean) => {
ModalCommands.push(
- modal(() => (
- <ConfirmModal
- title={i18n._(
- enabled ? PASSKEY_TWO_FACTOR_ENABLE_TITLE_DESCRIPTOR : PASSKEY_TWO_FACTOR_DISABLE_TITLE_DESCRIPTOR,
- )}
- description={i18n._(
- enabled
- ? PASSKEY_TWO_FACTOR_ENABLE_DESCRIPTION_DESCRIPTOR
- : hasTotpMfa
- ? PASSKEY_TWO_FACTOR_DISABLE_DESCRIPTION_WITH_TOTP_DESCRIPTOR
- : PASSKEY_TWO_FACTOR_DISABLE_DESCRIPTION_DESCRIPTOR,
- )}
- primaryText={i18n._(
- enabled ? PASSKEY_TWO_FACTOR_ENABLE_CONFIRM_DESCRIPTOR : PASSKEY_TWO_FACTOR_DISABLE_CONFIRM_DESCRIPTOR,
- )}
- primaryVariant={enabled ? 'primary' : 'danger'}
- onPrimary={() => applyPasskeyTwoFactor(enabled)}
- data-flx="user.account-security-tab.security-tab.handle-toggle-passkey-two-factor.confirm-modal"
- />
- )),
+ modal(() => {
+ const title = i18n._(
+ enabled ? PASSKEY_TWO_FACTOR_ENABLE_TITLE_DESCRIPTOR : PASSKEY_TWO_FACTOR_DISABLE_TITLE_DESCRIPTOR,
+ );
+ let descriptionDescriptor: typeof PASSKEY_TWO_FACTOR_ENABLE_DESCRIPTION_DESCRIPTOR;
+ if (enabled) {
+ descriptionDescriptor = PASSKEY_TWO_FACTOR_ENABLE_DESCRIPTION_DESCRIPTOR;
+ } else if (hasTotpMfa) {
+ descriptionDescriptor = PASSKEY_TWO_FACTOR_DISABLE_DESCRIPTION_WITH_TOTP_DESCRIPTOR;
+ } else {
+ descriptionDescriptor = PASSKEY_TWO_FACTOR_DISABLE_DESCRIPTION_DESCRIPTOR;
+ }
+ return (
+ <ConfirmModal
+ title={title}
+ description={i18n._(descriptionDescriptor)}
+ primaryText={i18n._(
+ enabled ? PASSKEY_TWO_FACTOR_ENABLE_CONFIRM_DESCRIPTOR : PASSKEY_TWO_FACTOR_DISABLE_CONFIRM_DESCRIPTOR,
+ )}
+ primaryVariant={enabled ? 'primary' : 'danger'}
+ onPrimary={() => applyPasskeyTwoFactor(enabled)}
+ data-flx="user.account-security-tab.security-tab.handle-toggle-passkey-two-factor.confirm-modal"
+ />
+ );
+ }),
);
};
const handleDeletePasskey = (credentialId: string) => {
@@ -316,22 +281,21 @@ export const SecurityTabContent: React.FC<SecurityTabProps> = observer(
)),
);
};
- if (!isClaimed) {
+ if (!mfaGate.allowed && !needsEmailVerification) {
+ const presentation = getAccountGatePresentation(i18n, mfaGate);
return (
<SettingsTabSection
title={<Trans>Security features</Trans>}
- description={
- <Trans>Claim your account to access security features like two-factor authentication and passkeys.</Trans>
- }
+ description={presentation.description}
data-flx="user.account-security-tab.security-tab.security-tab-content.settings-tab-section"
>
<Button
className={styles.claimButton}
fitContent
- onClick={() => openClaimAccountModal()}
+ onClick={presentation.onAction}
data-flx="user.account-security-tab.security-tab.security-tab-content.claim-button.open-claim-account-modal"
>
- {i18n._(CLAIM_ACCOUNT_DESCRIPTOR)}
+ {presentation.actionLabel}
</Button>
</SettingsTabSection>
);
@@ -346,19 +310,25 @@ export const SecurityTabContent: React.FC<SecurityTabProps> = observer(
<AccountSecurityCard
title={i18n._(TWO_FACTOR_AUTHENTICATION_DESCRIPTOR)}
description={i18n._(TWO_FACTOR_CARD_DESCRIPTION_DESCRIPTOR)}
- status={
- hasAnyMfa
- ? {label: i18n._(STATUS_ON_DESCRIPTOR), tone: 'success'}
- : {label: i18n._(STATUS_OFF_DESCRIPTOR), tone: 'muted'}
- }
data-flx="user.account-security-tab.security-tab.two-factor-card"
>
+ {needsEmailVerification && (
+ <AccountSecurityRow
+ label={
+ <Trans comment="Row in the two-factor authentication card shown when the account email is not confirmed yet. Two-factor authentication and passkeys stay locked until it is.">
+ Confirm your email to turn on two-factor authentication or add a passkey.
+ </Trans>
+ }
+ data-flx="user.account-security-tab.security-tab.verify-email-row"
+ >
+ <VerifyEmailButton data-flx="user.account-security-tab.security-tab.security-tab-content.verify-email-button">
+ <Trans>Confirm email</Trans>
+ </VerifyEmailButton>
+ </AccountSecurityRow>
+ )}
<AccountSecurityRow
label={<Trans>Authenticator app</Trans>}
description={totpDescription}
- warning={
- needsEmailVerification && !hasTotpMfa ? i18n._(VERIFY_EMAIL_BEFORE_AUTHENTICATOR_APP_DESCRIPTOR) : null
- }
data-flx="user.account-security-tab.security-tab.authenticator-app-row"
>
{hasTotpMfa ? (
@@ -427,14 +397,6 @@ export const SecurityTabContent: React.FC<SecurityTabProps> = observer(
<AccountSecurityCard
title={<Trans>Passkeys</Trans>}
description={<Trans>Use passkeys to sign in without a password</Trans>}
- status={
- passkeys.length > 0
- ? {
- label: i18n._(PASSKEY_COUNT_DESCRIPTOR, {count: passkeys.length}),
- tone: 'neutral',
- }
- : undefined
- }
action={
<Button
small={true}
@@ -448,11 +410,6 @@ export const SecurityTabContent: React.FC<SecurityTabProps> = observer(
}
data-flx="user.account-security-tab.security-tab.passkeys-card"
>
- {needsEmailVerification && (
- <AccountSecurityEmptyRow data-flx="user.account-security-tab.security-tab.passkeys-verify-email">
- {i18n._(VERIFY_EMAIL_BEFORE_PASSKEY_DESCRIPTOR)}
- </AccountSecurityEmptyRow>
- )}
{passkeys.length === 0 && !needsEmailVerification && (
<AccountSecurityEmptyRow data-flx="user.account-security-tab.security-tab.passkeys-empty">
<Trans>No passkeys yet. Add one to sign in with your fingerprint, face or a security key.</Trans>
@@ -506,6 +463,7 @@ export const SecurityTabContent: React.FC<SecurityTabProps> = observer(
label={<Trans>Require a passkey as your second factor</Trans>}
description={<Trans>Ask for a passkey after your password when you sign in</Trans>}
value={hasPasskeyMfa}
+ disabled={needsEmailVerification && !hasPasskeyMfa}
onChange={handleTogglePasskeyTwoFactor}
data-flx="user.account-security-tab.security-tab.security-tab-content.switch.passkey-two-factor"
/>