feat(auth): add username sign-in mode and recovery kits (#3215)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-05 14:10:07 +02:00
1 parent bf3d73a5f7
commit e1eecc3b6c
355 files changed
+52138 -24097

No files matched your search

@@ -7,7 +7,11 @@ import {
PASSWORD_DESCRIPTOR,
TWO_FACTOR_AUTHENTICATION_DESCRIPTOR,
} from '@app/features/i18n/utils/CommonMessageDescriptors';
import {shouldShowClaimedAccountSettings} from '@app/features/user/components/settings_utils/search_index/SearchIndexHelpers';
import {
shouldShowClaimedAccountSettings,
shouldShowEmailAccountSettings,
shouldShowRecoveryKitSettings,
} from '@app/features/user/components/settings_utils/search_index/SearchIndexHelpers';
import type {SearchableSettingDescriptor} from '@app/features/user/components/settings_utils/search_index/SearchIndexTypes';
import {
CODES_DESCRIPTOR,
@@ -31,6 +35,22 @@ const CHANGE_YOUR_EMAIL_ADDRESS_DESCRIPTOR = msg({
message: 'Change your email address',
comment: 'Settings search entry description. One-line summary of what the settings search entry controls.',
});
const RECOVERY_KIT_DESCRIPTOR = msg({
message: 'Recovery kit',
comment: 'Settings search entry label for the account recovery kit used to reset a forgotten password.',
});
const LOST_PASSWORD_DESCRIPTOR = msg({
message: 'Lost password',
comment: 'Settings search synonym. Used to match this term when the user types it in the settings search bar.',
});
const PRINT_DESCRIPTOR = msg({
message: 'Print',
comment: 'Settings search synonym. Used to match this term when the user types it in the settings search bar.',
});
const CREATE_A_RECOVERY_KIT_DESCRIPTOR = msg({
message: 'Create a recovery kit to reset a forgotten password',
comment: 'Settings search entry description. One-line summary of what the settings search entry controls.',
});
const CREDENTIALS_DESCRIPTOR = msg({
message: 'Credentials',
comment: 'Settings search synonym. Used to match this term when the user types it in the settings search bar.',
@@ -195,7 +215,7 @@ export const accountSecurityIndex: Array<SearchableSettingDescriptor> = [
label: EMAIL_DESCRIPTOR,
keywords: [EMAIL_DESCRIPTOR, MAIL_DESCRIPTOR, ADDRESS_DESCRIPTOR, CONTACT_DESCRIPTOR],
description: CHANGE_YOUR_EMAIL_ADDRESS_DESCRIPTOR,
isVisible: shouldShowClaimedAccountSettings,
isVisible: shouldShowEmailAccountSettings,
},
{
id: 'account-password',
@@ -212,6 +232,21 @@ export const accountSecurityIndex: Array<SearchableSettingDescriptor> = [
description: CHANGE_YOUR_PASSWORD_DESCRIPTOR,
isVisible: shouldShowClaimedAccountSettings,
},
{
id: 'account-recovery-kit',
tabType: 'account_security',
sectionId: 'account',
label: RECOVERY_KIT_DESCRIPTOR,
keywords: [
RECOVERY_KIT_DESCRIPTOR,
RECOVERY_DESCRIPTOR,
LOST_PASSWORD_DESCRIPTOR,
PRINT_DESCRIPTOR,
PASSWORD_DESCRIPTOR,
],
description: CREATE_A_RECOVERY_KIT_DESCRIPTOR,
isVisible: shouldShowRecoveryKitSettings,
},
{
id: 'account-2fa',
tabType: 'account_security',
@@ -1,7 +1,16 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
import Users from '@app/features/user/state/Users';
export function shouldShowClaimedAccountSettings(): boolean {
return Users.getCurrentUser()?.isClaimed() ?? true;
}
export function shouldShowEmailAccountSettings(): boolean {
return !RuntimeConfig.usesUsernameSignIn && shouldShowClaimedAccountSettings();
}
export function shouldShowRecoveryKitSettings(): boolean {
return RuntimeConfig.usesUsernameSignIn && shouldShowClaimedAccountSettings();
}