diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js --- a/lib/actions/user-actions.js +++ b/lib/actions/user-actions.js @@ -100,7 +100,7 @@ import { useSelector } from '../utils/redux-utils.js'; import { usingCommServicesAccessToken, - usingRestoreFlow, + useIsRestoreFlowEnabled, } from '../utils/services-utils.js'; import sleep from '../utils/sleep.js'; @@ -272,6 +272,7 @@ const callSecondaryDeviceLogOut = useSecondaryDeviceLogOut(); const checkIfPrimaryDevice = useCheckIfPrimaryDevice(); + const usingRestoreFlow = useIsRestoreFlowEnabled(); return React.useCallback(async () => { if (usingRestoreFlow) { @@ -287,6 +288,7 @@ callPrimaryDeviceLogOut, callSecondaryDeviceLogOut, checkIfPrimaryDevice, + usingRestoreFlow, ]); } diff --git a/lib/utils/services-utils.js b/lib/utils/services-utils.js --- a/lib/utils/services-utils.js +++ b/lib/utils/services-utils.js @@ -4,6 +4,7 @@ import { getMessageForException } from './errors.js'; import type { AuthMetadata } from '../shared/identity-client-context.js'; +import { useIsCurrentUserStaff } from '../shared/staff-utils.js'; // If this is true then we're using the identity service for auth. After we // auth, the identity service gives us a CSAT, which we can use to auth with @@ -19,10 +20,10 @@ // an authoritative keyserver for things like DMs. const relyingOnAuthoritativeKeyserver = true; -// If this is true, then we're using the login 2.0, which means that a user +// If this returns true, then we're using the login 2.0, which means that a user // can either restore an account (primary login) or log in using the QR code // (secondary login). -const usingRestoreFlow = false; +const useIsRestoreFlowEnabled = useIsCurrentUserStaff; function createHTTPAuthorizationHeader(authMetadata: AuthMetadata): string { // explicit destructure to make it future-proof @@ -55,7 +56,7 @@ usingCommServicesAccessToken, supportingMultipleKeyservers, relyingOnAuthoritativeKeyserver, - usingRestoreFlow, + useIsRestoreFlowEnabled, createHTTPAuthorizationHeader, createDefaultHTTPRequestHeaders, httpResponseIsInvalidCSAT, diff --git a/native/account/logged-out-modal.react.js b/native/account/logged-out-modal.react.js --- a/native/account/logged-out-modal.react.js +++ b/native/account/logged-out-modal.react.js @@ -30,7 +30,7 @@ import { useDispatch } from 'lib/utils/redux-utils.js'; import { usingCommServicesAccessToken, - usingRestoreFlow, + useIsRestoreFlowEnabled, } from 'lib/utils/services-utils.js'; import { splashBackgroundURI } from './background-info.js'; @@ -442,6 +442,8 @@ styles.loadingIndicator, ]); + const usingRestoreFlow = useIsRestoreFlowEnabled(); + const buttonsViewOpacity = useAnimatedStyle(() => ({ opacity: buttonOpacity.value, })); @@ -534,6 +536,7 @@ styles.siweOrText, styles.siweOrRightHR, styles.signInButtons, + usingRestoreFlow, ]); const windowWidth = dimensions.width; diff --git a/native/account/qr-code-screen.react.js b/native/account/qr-code-screen.react.js --- a/native/account/qr-code-screen.react.js +++ b/native/account/qr-code-screen.react.js @@ -9,7 +9,7 @@ import { qrCodeLinkURL } from 'lib/facts/links.js'; import { platformToIdentityDeviceType } from 'lib/types/identity-service-types.js'; import { getConfig } from 'lib/utils/config.js'; -import { usingRestoreFlow } from 'lib/utils/services-utils.js'; +import { useIsRestoreFlowEnabled } from 'lib/utils/services-utils.js'; import AuthButtonContainer from './auth-components/auth-button-container.react.js'; import AuthContainer from './auth-components/auth-container.react.js'; @@ -48,6 +48,8 @@ const styles = useStyles(unboundStyles); + const usingRestoreFlow = useIsRestoreFlowEnabled(); + let primaryRestoreButton = null; const goToRestoreFlow = React.useCallback(() => { props.navigation.navigate(RestorePromptScreenRouteName); diff --git a/native/account/registration/existing-ethereum-account.react.js b/native/account/registration/existing-ethereum-account.react.js --- a/native/account/registration/existing-ethereum-account.react.js +++ b/native/account/registration/existing-ethereum-account.react.js @@ -18,7 +18,7 @@ import { useDispatch } from 'lib/utils/redux-utils.js'; import { usingCommServicesAccessToken, - usingRestoreFlow, + useIsRestoreFlowEnabled, } from 'lib/utils/services-utils.js'; import type { AuthNavigationProp } from './auth-navigator.react.js'; @@ -142,6 +142,7 @@ setCachedSelections, ]); + const usingRestoreFlow = useIsRestoreFlowEnabled(); const useLegacyFlow = !backupData || !usingRestoreFlow; const openRestoreFlow = React.useCallback(() => { diff --git a/native/backup/backup-handler.js b/native/backup/backup-handler.js --- a/native/backup/backup-handler.js +++ b/native/backup/backup-handler.js @@ -19,7 +19,7 @@ import { getMessageForException } from 'lib/utils/errors.js'; import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; -import { usingRestoreFlow } from 'lib/utils/services-utils.js'; +import { useIsRestoreFlowEnabled } from 'lib/utils/services-utils.js'; import { useClientBackup } from './use-client-backup.js'; import { useMigrationToNewFlow } from './use-migration-to-new-flow.js'; @@ -99,6 +99,8 @@ } }, [canPerformBackupOperation, stopBackupHandler]); + const usingRestoreFlow = useIsRestoreFlowEnabled(); + const process = React.useCallback(async () => { let step = 'starting backup handler'; try { @@ -202,6 +204,7 @@ showAlertToStaff, socketState.isAuthorized, startBackupHandler, + usingRestoreFlow, ]); React.useEffect(() => { diff --git a/native/navigation/deep-links-context-provider.react.js b/native/navigation/deep-links-context-provider.react.js --- a/native/navigation/deep-links-context-provider.react.js +++ b/native/navigation/deep-links-context-provider.react.js @@ -25,7 +25,7 @@ import { errorMessageIsInvalidCSAT, usingCommServicesAccessToken, - usingRestoreFlow, + useIsRestoreFlowEnabled, } from 'lib/utils/services-utils.js'; import { @@ -106,6 +106,7 @@ const dispatchActionPromise = useDispatchActionPromise(); const validateLink = useVerifyInviteLink(keyserverOverride); const navigation = useNavigation(); + const usingRestoreFlow = useIsRestoreFlowEnabled(); React.useEffect(() => { void (async () => { if (!loggedIn || !currentLink) { @@ -165,6 +166,7 @@ navigation, invalidTokenLogOut, showVersionUnsupportedAlert, + usingRestoreFlow, ]); React.useEffect(() => { diff --git a/native/profile/profile-screen.react.js b/native/profile/profile-screen.react.js --- a/native/profile/profile-screen.react.js +++ b/native/profile/profile-screen.react.js @@ -31,7 +31,7 @@ } from 'lib/utils/redux-promise-utils.js'; import { usingCommServicesAccessToken, - usingRestoreFlow, + useIsRestoreFlowEnabled, } from 'lib/utils/services-utils.js'; import type { ProfileNavigationProp } from './profile.react.js'; @@ -183,6 +183,7 @@ +isAccountWithPassword: boolean, +onCreateDMThread: () => Promise, +currentUserFID: ?string, + +usingRestoreFlow: boolean, }; class ProfileScreen extends React.PureComponent { @@ -258,7 +259,7 @@ } let linkedDevices; - if (usingRestoreFlow) { + if (this.props.usingRestoreFlow) { linkedDevices = ( ); @@ -358,7 +359,7 @@ if (this.loggedOutOrLoggingOut) { return; } - if (usingRestoreFlow) { + if (this.props.usingRestoreFlow) { this.onPressNewLogout(); return; } @@ -613,6 +614,8 @@ })(); }, [checkIfPrimaryDevice]); + const usingRestoreFlow = useIsRestoreFlowEnabled(); + return ( ); }); diff --git a/web/account/log-in-form.react.js b/web/account/log-in-form.react.js --- a/web/account/log-in-form.react.js +++ b/web/account/log-in-form.react.js @@ -14,7 +14,7 @@ import { platformToIdentityDeviceType } from 'lib/types/identity-service-types.js'; import { getConfig } from 'lib/utils/config.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; -import { usingRestoreFlow } from 'lib/utils/services-utils.js'; +import { useIsRestoreFlowEnabled } from 'lib/utils/services-utils.js'; import HeaderSeparator from './header-separator.react.js'; import css from './log-in-form.css'; @@ -207,6 +207,7 @@ } function LoginFormWrapper(): React.Node { + const usingRestoreFlow = useIsRestoreFlowEnabled(); if (!usingRestoreFlow) { return ; } diff --git a/web/settings/account-settings.react.js b/web/settings/account-settings.react.js --- a/web/settings/account-settings.react.js +++ b/web/settings/account-settings.react.js @@ -27,7 +27,7 @@ getContentSigningKey, } from 'lib/utils/crypto-utils.js'; import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js'; -import { usingRestoreFlow } from 'lib/utils/services-utils.js'; +import { useIsRestoreFlowEnabled } from 'lib/utils/services-utils.js'; import css from './account-settings.css'; import AppearanceChangeModal from './appearance-change-modal.react.js'; @@ -59,6 +59,7 @@ const sendSecondaryDeviceLogoutRequest = useSecondaryDeviceLogOut(); const dispatchActionPromise = useDispatchActionPromise(); const checkIfPrimaryDevice = useCheckIfPrimaryDevice(); + const usingRestoreFlow = useIsRestoreFlowEnabled(); const logOutUser = React.useCallback(async () => { // if web is primary device, we're on legacy flow const isPrimaryDevice = await checkIfPrimaryDevice(); @@ -74,6 +75,7 @@ dispatchActionPromise, sendLegacyLogoutRequest, sendSecondaryDeviceLogoutRequest, + usingRestoreFlow, ]); const identityContext = React.useContext(IdentityClientContext);