Skip to content

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

TypeScript fluxerfluxerapp

feat(app): route sign-in through identifier-first steps

Hampusd50bdc3e6734
diff --git a/fluxer_app/src/features/auth/flow/AuthLoginLayout.tsx b/fluxer_app/src/features/auth/flow/AuthLoginLayout.tsx
index 14c12f384..530bf1b7b 100644
--- a/fluxer_app/src/features/auth/flow/AuthLoginLayout.tsx
+++ b/fluxer_app/src/features/auth/flow/AuthLoginLayout.tsx
@@ -4,20 +4,23 @@ import {Routes} from '@app/app/Routes';
import {detectDomainMigrationInstallKind} from '@app/features/app/domain_migration/DomainMigrationBrowser';
import type {RuntimeConfigSnapshot} from '@app/features/app/state/InstanceSnapshotStore';
import RuntimeConfig, {describeAPIEndpoint, type InstanceSsoConfig} from '@app/features/app/state/RuntimeConfig';
+import {getAccountDisplayLabels} from '@app/features/auth/AccountDisplayUtils';
import {
FORGOT_YOUR_PASSWORD_DESCRIPTOR,
SIGN_IN_WITH_BROWSER_DESCRIPTOR,
} from '@app/features/auth/AuthMessageDescriptors';
import * as AuthenticationCommands from '@app/features/auth/commands/AuthenticationCommands';
+import {AgeBlockedRemovalGate} from '@app/features/auth/components/AgeBlockedRemovalGate';
+import {SIGN_IN_AGAIN_AS_DESCRIPTOR} from '@app/features/auth/components/accounts/AccountList';
import {AccountSelector} from '@app/features/auth/components/accounts/AccountSelector';
import styles from '@app/features/auth/components/pages/LoginPage.module.css';
import {AuthRouterLink} from '@app/features/auth/flow/AuthRouterLink';
import {
AuthSsoPanel,
- CONTINUE_WITH_SSO_DESCRIPTOR,
isInstanceSsoAvailable,
isSsoLoginEnforced,
resolveAuthPanelSso,
+ SsoButtonLabel,
} from '@app/features/auth/flow/AuthSsoPanel';
import {
AuthLoginBrowserStep,
@@ -51,14 +54,16 @@ import {useDesktopClientIntroFlow} from '@app/features/auth/flow/client_intro/us
import DesktopHandoffAccountSelector from '@app/features/auth/flow/DesktopHandoffAccountSelector';
import {HandoffApprovalFlow} from '@app/features/auth/flow/HandoffApprovalFlow';
import IpAuthorizationScreen from '@app/features/auth/flow/IpAuthorizationScreen';
+import {AuthIdentifierFirstStep} from '@app/features/auth/flow/identifier_first/AuthIdentifierFirstStep';
+import {markSsoAutoStartSpent, useSsoAutoStart, withoutSsoStartRequest} from '@app/features/auth/flow/SsoAutoStart';
import {useAuthPresentation} from '@app/features/auth/flow/useAuthPresentation';
+import {type StepTitleChangeHandler, useReportStepTitle} from '@app/features/auth/flow/useReportStepTitle';
import {getAuthErrorMessage} from '@app/features/auth/hooks/useAuthForm';
import {
PasskeyLoginCapability,
resolveInitialPasskeyLoginCapability,
resolvePasskeyLoginCapability,
type StoredAccountLoginPayload,
- sessionExpiredMessage,
useAccountSwitchController,
useLoginFormController,
} from '@app/features/auth/hooks/useLoginFlow';
@@ -74,7 +79,9 @@ import {
import {AuthCardVariant, AuthLayoutContentMode, useAuthLayoutContext} from '@app/features/auth/state/AuthLayoutContext';
import type {AuthRuntimeTarget} from '@app/features/auth/state/AuthRuntimeTarget';
import {accountLoginIdentifierField, accountSignInIdentifier} from '@app/features/auth/utils/AccountSignInIdentifier';
+import {logoutStoredAccountFromSwitcher} from '@app/features/auth/utils/AccountSwitcherModalUtils';
import {shouldOfferOldAppSignIn} from '@app/features/auth/utils/OldAppSignIn';
+import {describePasskeyPromptEnded} from '@app/features/auth/utils/PasskeyErrorMessages';
import {
BACK_DESCRIPTOR,
COULDN_T_VERIFY_WITH_PASSKEY_DESCRIPTOR,
@@ -84,8 +91,11 @@ import * as RouterUtils from '@app/features/navigation/utils/RouterUtils';
import {useLocation} from '@app/features/platform/components/router/RouterReact';
import type {Account} from '@app/features/platform/state/AuthSession';
import {Button, ButtonVariant} from '@app/features/ui/button/Button';
+import * as ToastCommands from '@app/features/ui/commands/ToastCommands';
import {SteppedCarousel} from '@app/features/ui/stepped_carousel/SteppedCarousel';
import {isDesktop, navigateToExternalURL} from '@app/features/ui/utils/NativeUtils';
+import type {GuildEntryResult} from '@fluxer/schema/src/domains/user/AccountSchemas';
+import type {MessageDescriptor} from '@lingui/core';
import {msg} from '@lingui/core/macro';
import {useLingui} from '@lingui/react/macro';
import {observer} from 'mobx-react-lite';
@@ -121,6 +131,7 @@ export interface AuthLoginLayoutProps {
readonly registerLink: ReactElement<Record<string, unknown>>;
readonly onLoginComplete?: ((payload: LoginSuccessPayload) => Promise<void> | void) | null;
readonly onBackActionChange?: ((action: (() => void) | null) => void) | null;
+ readonly onStepTitleChange?: StepTitleChangeHandler | null;
readonly completeLoginRedirectPath: string | null;
readonly forceCredentials?: boolean;
readonly startWithAddAccount?: boolean;
@@ -128,6 +139,7 @@ export interface AuthLoginLayoutProps {
readonly ssoRedirectPath?: string | null;
readonly suppressInlineBackButtons?: boolean;
readonly initialIdentifier?: string | null;
+ readonly allowSsoAutoStart?: boolean;
}
interface HandoffAccountsRequest {
@@ -164,6 +176,7 @@ interface AuthBackActionRequest {
readonly accountListBackAction: (() => void) | null;
readonly authLoginStep: AuthLoginStep;
readonly browserBackAction: (() => void) | null;
+ readonly forceCredentials: boolean;
readonly handleBackFromBrowser: () => void;
readonly handleBackFromCredentials: () => void;
readonly handleBackFromIpAuthorization: () => void;
@@ -179,6 +192,10 @@ function getInitialInstanceUrl(snapshot: RuntimeConfigSnapshot | null): string |
return describeAPIEndpoint(snapshot.apiEndpoint);
}
+function usesIdentifierFirst(snapshot: RuntimeConfigSnapshot | null): boolean {
+ return snapshot?.features.identifier_first === true;
+}
+
function resolveEmailsEnabled(snapshot: RuntimeConfigSnapshot | null): boolean {
return snapshot?.features.emails_enabled ?? false;
}
@@ -273,6 +290,13 @@ function resolveEffectiveHandoffMode(handoffMode: DesktopHandoffMode, hasHandoff
return handoffMode;
}
+function isSsoAutoStartStep(step: AuthLoginStep, startRequested: boolean): boolean {
+ if (step === AuthLoginStep.SSO || step === AuthLoginStep.METHOD || step === AuthLoginStep.CREDENTIALS) {
+ return true;
+ }
+ return startRequested && step === AuthLoginStep.ACCOUNT;
+}
+
function resolveAuthCardVariant(step: AuthLoginStep): AuthCardVariant {
if (step === AuthLoginStep.DESKTOP_HANDOFF_APPROVAL) {
return AuthCardVariant.COMPACT;
@@ -283,16 +307,6 @@ function resolveAuthCardVariant(step: AuthLoginStep): AuthCardVariant {
return AuthCardVariant.STANDARD;
}
-function shouldUseFullscreenAuthPresentation(showClientWelcome: boolean, step: AuthLoginStep): boolean {
- if (showClientWelcome) {
- return true;
- }
- if (step === AuthLoginStep.ACCOUNT) {
- return true;
- }
- return step === AuthLoginStep.DESKTOP_HANDOFF_ACCOUNT;
-}
-
function resolveStepError(showAccountSelector: boolean, switchError: string | null): string | null {
if (showAccountSelector) {
return null;
@@ -300,6 +314,17 @@ function resolveStepError(showAccountSelector: boolean, switchError: string | nu
return switchError;
}
+function resolveStepTitleDescriptor(step: AuthLoginStep): MessageDescriptor | null {
+ switch (step) {
+ case AuthLoginStep.INSTANCE:
+ return CHOOSE_INSTANCE_DESCRIPTOR;
+ case AuthLoginStep.BROWSER:
+ return SIGN_IN_WITH_BROWSER_DESCRIPTOR;
+ default:
+ return null;
+ }
+}
+
function resolveAuthStepTitle(title: ReactNode, fallbackTitle: ReactNode): ReactNode {
if (title == null) {
return fallbackTitle;
@@ -307,6 +332,17 @@ function resolveAuthStepTitle(title: ReactNode, fallbackTitle: ReactNode): React
return title;
}
+function resolveReloginTitle(account: Account | null, format: (accountLabel: string) => string): string | null {
+ if (account == null) {
+ return null;
+ }
+ const labels = getAccountDisplayLabels(account);
+ if (!labels.available || labels.displayLabel === '') {
+ return null;
+ }
+ return format(labels.displayLabel);
+}
+
function resolveBrowserPrefillIdentifier(prefillIdentifier: string | null, formEmail: string): string | null {
if (prefillIdentifier != null) {
return prefillIdentifier;
@@ -347,6 +383,7 @@ function resolveAuthBackAction({
accountListBackAction,
authLoginStep,
browserBackAction,
+ forceCredentials,
handleBackFromBrowser,
handleBackFromCredentials,
handleBackFromIpAuthorization,
@@ -361,7 +398,7 @@ function resolveAuthBackAction({
}
return handleBackFromBrowser;
case AuthLoginStep.CREDENTIALS:
- return handleBackFromCredentials;
+ return forceCredentials ? null : handleBackFromCredentials;
case AuthLoginStep.IP_AUTHORIZATION:
return handleBackFromIpAuthorization;
case AuthLoginStep.METHOD:
@@ -391,6 +428,7 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
registerLink,
onLoginComplete = null,
onBackActionChange = null,
+ onStepTitleChange = null,
completeLoginRedirectPath,
forceCredentials = false,
startWithAddAccount = false,
@@ -398,6 +436,7 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
ssoRedirectPath: explicitSsoRedirectPath = null,
suppressInlineBackButtons = false,
initialIdentifier = null,
+ allowSsoAutoStart = true,
}: AuthLoginLayoutProps) {
const {i18n} = useLingui();
const {setContentMode} = useAuthLayoutContext();
@@ -405,8 +444,9 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
const currentAccountKey = Accounts.currentAccountKey;
const accounts = switcherAccounts();
const hasStoredAccounts = accounts.length > 0;
- const shouldShowInstanceSelector = shouldRenderInstanceStep();
+ const shouldShowInstanceSelector = shouldRenderInstanceStep() && runtimeTarget.canChangeInstance;
const [isStartingSso, setIsStartingSso] = useState(false);
+ const [browserStepStartsSso, setBrowserStepStartsSso] = useState(false);
const resolvedAuthRuntimeSnapshot = runtimeTarget.snapshot;
const initialInstanceSelected = runtimeTarget.initialSnapshot != null;
const ssoConfig = resolvedAuthRuntimeSnapshot == null ? null : resolveAuthPanelSso(resolvedAuthRuntimeSnapshot);
@@ -456,10 +496,11 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
} = flow;
const [instanceBackAction, setInstanceBackAction] = useState<(() => void) | null>(null);
const [browserBackAction, setBrowserBackAction] = useState<(() => void) | null>(null);
+ const [childStepTitle, setChildStepTitle] = useState<string | null>(null);
const ssoRedirectPath = resolveSsoRedirectPath({
explicitSsoRedirectPath,
desktopHandoff,
- handoffLocationPath: `${location.pathname}${location.search}`,
+ handoffLocationPath: withoutSsoStartRequest(`${location.pathname}${location.search}`),
redirectPath,
});
const shouldUseDesktopClientSetup = resolveShouldUseDesktopClientSetup({
@@ -509,6 +550,11 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
[completeLoginRedirectPath, desktopHandoff, handoff, onLoginComplete, resolvedAuthRuntimeSnapshot],
);
const handleShowBrowserStep = useCallback(() => {
+ setBrowserStepStartsSso(false);
+ enterBrowserStep();
+ }, [enterBrowserStep]);
+ const handleShowSsoBrowserStep = useCallback(() => {
+ setBrowserStepStartsSso(true);
enterBrowserStep();
}, [enterBrowserStep]);
const {form, identifierField, isLoading, fieldErrors, handlePasskeyLogin, isPasskeyLoading, connectingMessage} =
@@ -537,6 +583,9 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
runtimeSnapshot: requireAuthInstanceSnapshot(resolvedAuthRuntimeSnapshot),
});
},
+ onCancelled: () => {
+ ToastCommands.error(describePasskeyPromptEnded(i18n));
+ },
onFailure: () => {
setSwitchError(i18n._(COULDN_T_VERIFY_WITH_PASSKEY_DESCRIPTOR));
},
@@ -546,8 +595,9 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
form.setValue('login', '');
form.setValue('password', '');
}, [form.setValue]);
+ const [reloginAccount, setReloginAccount] = useState<Account | null>(null);
const showLoginFormForAccount = useCallback(
- (account: Account, message: string | null) => {
+ (account: Account) => {
const identifier = accountSignInIdentifier(account);
const runtimeSnapshot = resolveAccountInstance(account);
clearCredentials();
@@ -557,7 +607,8 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
} else {
runtimeTarget.select(runtimeSnapshot);
}
- showFormForAccount(identifier, message, runtimeSnapshot != null);
+ setReloginAccount(account);
+ showFormForAccount(identifier, null, runtimeSnapshot != null);
},
[clearCredentials, form.setValue, runtimeTarget, showFormForAccount],
);
@@ -573,7 +624,15 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
},
[completeLoginRedirectPath, onLoginComplete, redirectPath],
);
+ const handleSignOutStoredAccount = useCallback(
+ async (account: Account) => {
+ setSwitchError(null);
+ await logoutStoredAccountFromSwitcher(account, setSwitchError);
+ },
+ [setSwitchError],
+ );
const {isSwitching, switchToAccount} = useAccountSwitchController({
+ redirectPath,
onError: setSwitchError,
onSessionExpired: showLoginFormForAccount,
onLoginWithStoredAccount: handleStoredAccountLogin,
@@ -614,10 +673,12 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
hasStoredAccounts && !desktopHandoff && !forceCredentials && !hasInitialIdentifier(initialIdentifier);
const handleBackFromCredentials = useCallback(() => {
clearCredentials();
+ setReloginAccount(null);
backFromCredentials(canReturnToAccountList);
}, [backFromCredentials, canReturnToAccountList, clearCredentials]);
const handleBackToAccountList = useCallback(() => {
clearCredentials();
+ setReloginAccount(null);
backToAccountList();
}, [backToAccountList, clearCredentials]);
const handleBackFromBrowser = useCallback(() => {
@@ -702,18 +763,20 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
}, [form.setValue, identifierField, prefillIdentifier]);
const handleAddAnotherAccount = useCallback(() => {
clearCredentials();
+ setReloginAccount(null);
runtimeTarget.reset();
addAnotherAccount();
}, [addAnotherAccount, clearCredentials, runtimeTarget]);
const handleHandoffReLogin = useCallback(
(account: Account) => {
- showLoginFormForAccount(account, sessionExpiredMessage(i18n, account));
+ showLoginFormForAccount(account);
handoff.switchToLogin();
},
- [handoff, i18n, showLoginFormForAccount],
+ [handoff, showLoginFormForAccount],
);
const handleChooseHandoffAccount = useCallback(() => {
clearCredentials();
+ setReloginAccount(null);
runtimeTarget.reset();
addAnotherAccount();
handoff.retry();
@@ -723,11 +786,12 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
return;
}
if (isDesktop()) {
- enterBrowserStep();
+ handleShowSsoBrowserStep();
return;
}
try {
setIsStartingSso(true);
+ markSsoAutoStartSpent();
const runtimeSnapshot = requireAuthInstanceSnapshot(resolvedAuthRuntimeSnapshot);
const {authorizationUrl} = await startSsoLogin({
redirectTo: ssoRedirectPath,
@@ -739,7 +803,7 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
} finally {
setIsStartingSso(false);
}
- }, [enterBrowserStep, i18n, resolvedAuthRuntimeSnapshot, setSwitchError, ssoConfig, ssoRedirectPath]);
+ }, [handleShowSsoBrowserStep, i18n, resolvedAuthRuntimeSnapshot, setSwitchError, ssoConfig, ssoRedirectPath]);
const authLoginStep: AuthLoginStep = useMemo(() => {
return selectAuthLoginStep({
desktopHandoff,
@@ -768,6 +832,21 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
showAccountSelector,
showBrowserStep,
]);
+ const isOnSsoAutoStartStep = useCallback(
+ (startRequested: boolean) => isSsoAutoStartStep(authLoginStep, startRequested),
+ [authLoginStep],
+ );
+ useSsoAutoStart({
+ allowed: allowSsoAutoStart,
+ desktopApp: isDesktop(),
+ desktopHandoff,
+ onSignInStep: isOnSsoAutoStartStep,
+ ssoAvailable: isInstanceSsoAvailable(ssoConfig),
+ ssoEnforced: isSsoEnforced,
+ pathname: location.pathname,
+ search: location.search,
+ start: handleStartSso,
+ });
const cardVariant = useMemo<AuthCardVariant>(() => resolveAuthCardVariant(authLoginStep), [authLoginStep]);
const accountListBackAction = useMemo<(() => void) | null>(() => {
if (desktopHandoff) {
@@ -791,6 +870,7 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
accountListBackAction,
authLoginStep,
browserBackAction,
+ forceCredentials,
handleBackFromBrowser,
handleBackFromCredentials,
handleBackFromIpAuthorization,
@@ -802,6 +882,7 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
accountListBackAction,
authLoginStep,
browserBackAction,
+ forceCredentials,
handleBackFromBrowser,
handleBackFromCredentials,
handleBackFromIpAuthorization,
@@ -818,12 +899,20 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
notifyBackActionChange(backAction);
return () => notifyBackActionChange(null);
}, [backAction, onBackActionChange]);
- const shouldUseFullscreenPresentation = shouldUseFullscreenAuthPresentation(showClientWelcome, authLoginStep);
+ const childStepTitleChange = onStepTitleChange == null ? null : setChildStepTitle;
+ const stepTitleDescriptor = resolveStepTitleDescriptor(authLoginStep);
+ let stepTitle: string | null = stepTitleDescriptor == null ? null : i18n._(stepTitleDescriptor);
+ if (authLoginStep === AuthLoginStep.IP_AUTHORIZATION || authLoginStep === AuthLoginStep.SSO) {
+ stepTitle = childStepTitle;
+ }
+ useReportStepTitle(onStepTitleChange, stepTitle);
useAuthPresentation(
- shouldUseFullscreenPresentation
+ showClientWelcome
? {contentMode: AuthLayoutContentMode.FULL, variant: AuthCardVariant.STANDARD}
: {contentMode: AuthLayoutContentMode.CARD, variant: cardVariant},
);
+ const formTitle =
+ title ?? resolveReloginTitle(reloginAccount, (accountLabel) => i18n._(SIGN_IN_AGAIN_AS_DESCRIPTOR, {accountLabel}));
const renderOldAppSignIn = (): ReactNode => {
if (!offerOldAppSignIn) {
return null;
@@ -854,7 +943,7 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
extraTopContent={extraTopContent}
identifierField={identifierField}
showTitle={showTitle}
- title={resolveAuthStepTitle(title, i18n._(WELCOME_BACK_DESCRIPTOR))}
+ title={resolveAuthStepTitle(formTitle, i18n._(WELCOME_BACK_DESCRIPTOR))}
switchError={resolveStepError(showAccountSelector, switchError)}
leadingAction={renderOldAppSignIn()}
disabled={passkeyControlsDisabled || isStartingSso}
@@ -868,7 +957,12 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
onBackToInstance={inlineInstanceBackAction}
ssoAction={resolveMethodSsoAction({
ssoConfig,
- label: i18n._(CONTINUE_WITH_SSO_DESCRIPTOR),
+ label: (
+ <SsoButtonLabel
+ ssoConfig={ssoConfig}
+ data-flx="auth.flow.auth-login-layout.render-method-step.sso-button-label"
+ />
+ ),
isStarting: isStartingSso,
onStart: handleStartSso,
})}
@@ -876,6 +970,83 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
/>
);
};
+ const handleIdentifierFirstSignedIn = async (payload: LoginSuccessPayload, entry: GuildEntryResult | null) => {
+ await handleLoginSuccess(payload);
+ if (desktopHandoff) {
+ return;
+ }
+ if (entry !== null) {
+ RouterUtils.replaceWith(Routes.guildChannel(entry.guild_id));
+ return;
+ }
+ if (redirectPath != null && redirectPath !== '') {
+ RouterUtils.replaceWith(redirectPath);
+ }
+ };
+ const renderIdentifierFirstAlternatives = (): ReactNode => {
+ const actions: Array<ReactNode> = [];
+ const oldAppSignIn = renderOldAppSignIn();
+ if (oldAppSignIn !== null) {
+ actions.push(oldAppSignIn);
+ }
+ if (isInstanceSsoAvailable(ssoConfig)) {
+ actions.push(
+ <Button
+ key="sso"
+ fitContainer
+ variant={ButtonVariant.SECONDARY}
+ submitting={isStartingSso}
+ disabled={passkeyControlsDisabled}
+ onClick={handleStartSso}
+ data-flx="auth.flow.auth-login-layout.identifier-first.button.sso"
+ >
+ <SsoButtonLabel
+ ssoConfig={ssoConfig}
+ data-flx="auth.flow.auth-login-layout.render-identifier-first-alternatives.sso-button-label"
+ />
+ </Button>,
+ );
+ }
+ if (resolveShouldOfferBrowserStep() && resolvedAuthRuntimeSnapshot != null) {
+ actions.push(
+ <Button
+ key="browser"
+ fitContainer
+ variant={ButtonVariant.SECONDARY}
+ disabled={passkeyControlsDisabled}
+ onClick={handleShowBrowserStep}
+ data-flx="auth.flow.auth-login-layout.identifier-first.button.browser"
+ >
+ {i18n._(SIGN_IN_WITH_BROWSER_DESCRIPTOR)}
+ </Button>,
+ );
+ }
+ return actions.length === 0 ? null : actions;
+ };
+ const renderIdentifierFirstStep = (): ReactNode => (
+ <AuthIdentifierFirstStep
+ runtimeSnapshot={requireAuthInstanceSnapshot(resolvedAuthRuntimeSnapshot)}
+ title={formTitle}
+ showTitle={showTitle}
+ extraTopContent={extraTopContent}
+ notice={resolveStepError(showAccountSelector, switchError)}
+ initialEmail={prefillIdentifier ?? initialIdentifier}
+ inviteCode={inviteCode}
+ passkeyAvailable={showPasskeyOption && isPasskeyAvailableForCurrentClient(resolvedAuthRuntimeSnapshot)}
+ passkeyDisabled={passkeyControlsDisabled}
+ onPasskeyLogin={handlePasskeyLogin}
+ alternativeActions={renderIdentifierFirstAlternatives()}
+ onSignedIn={handleIdentifierFirstSignedIn}
+ onRequireMfa={(challenge) => {
+ AuthenticationCommands.setMfaTicket({
+ ...challenge,
+ runtimeSnapshot: requireAuthInstanceSnapshot(resolvedAuthRuntimeSnapshot),
+ });
+ }}
+ onRequireIpAuthorization={setIpAuthChallenge}
+ data-flx="auth.flow.auth-login-layout.identifier-first-step"
+ />
+ );
const renderCredentialFooterStart = (): ReactNode => {
if (suppressInlineBackButtons) {
return null;
@@ -915,7 +1086,7 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
<AuthLoginCredentialStepPanel
extraTopContent={extraTopContent}
showTitle={showTitle}
- title={resolveAuthStepTitle(title, i18n._(WELCOME_BACK_DESCRIPTOR))}
+ title={resolveAuthStepTitle(formTitle, i18n._(WELCOME_BACK_DESCRIPTOR))}
switchError={resolveStepError(showAccountSelector, switchError)}
form={form}
isLoading={isLoading}
@@ -948,7 +1119,8 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
<AuthSsoPanel
redirectPath={ssoRedirectPath ?? undefined}
runtimeSnapshot={runtimeSnapshot}
- onStart={isDesktop() ? handleShowBrowserStep : undefined}
+ onStart={isDesktop() ? handleShowSsoBrowserStep : undefined}
+ onStepTitleChange={childStepTitleChange}
dataFlx="auth.flow.auth-login-layout.sso-panel"
data-flx="auth.flow.auth-login-layout.render-auth-login-step.auth-sso-panel"
/>
@@ -962,6 +1134,7 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
error={switchError}
disabled={isSwitching}
onSelectAccount={switchToAccount}
+ onSignOutAccount={handleSignOutStoredAccount}
onAddAccount={handleAddAnotherAccount}
data-flx="auth.flow.auth-login-layout.account-selector"
/>
@@ -978,6 +1151,7 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
runtimeSnapshot={runtimeSnapshot}
onAuthorized={handleIpAuthorizationComplete}
onBack={suppressInlineBackButtons ? undefined : handleBackFromIpAuthorization}
+ onStepTitleChange={childStepTitleChange}
data-flx="auth.flow.auth-login-layout.ip-authorization-screen"
/>
);
@@ -986,6 +1160,7 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
return (
<AuthLoginInstanceStep
extraTopContent={extraTopContent}
+ showTitle={onStepTitleChange == null}
title={i18n._(CHOOSE_INSTANCE_DESCRIPTOR)}
initialInstanceUrl={getInitialInstanceUrl(resolvedAuthRuntimeSnapshot)}
onContinue={handleContinueFromInstance}
@@ -1015,8 +1190,18 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
/>
);
}
+ if (
+ usesIdentifierFirst(resolvedAuthRuntimeSnapshot) &&
+ (authLoginStep === AuthLoginStep.METHOD || authLoginStep === AuthLoginStep.CREDENTIALS)
+ ) {
+ return renderIdentifierFirstStep();
+ }
if (authLoginStep === AuthLoginStep.METHOD) {
- return renderMethodStep();
+ return (
+ <AgeBlockedRemovalGate data-flx="auth.flow.auth-login-layout.age-blocked-removal-gate">
+ {renderMethodStep()}
+ </AgeBlockedRemovalGate>
+ );
}
if (authLoginStep === AuthLoginStep.BROWSER) {
const runtimeSnapshot = requireAuthInstanceSnapshot(resolvedAuthRuntimeSnapshot);
@@ -1036,6 +1221,7 @@ export const AuthLoginLayout = observer(function AuthLoginLayout({
onChangeInstance={instanceSelectorChangeAction}
onSuccess={handleBrowserLoginSuccess}
showBackButton={!suppressInlineBackButtons}
+ startSso={browserStepStartsSso}
data-flx="auth.flow.auth-login-layout.auth-login-browser-step"
/>
);
diff --git a/fluxer_app/src/features/auth/flow/AuthRuntimeTargetGate.tsx b/fluxer_app/src/features/auth/flow/AuthRuntimeTargetGate.tsx
index fa4ac1f65..2531fadb4 100644
--- a/fluxer_app/src/features/auth/flow/AuthRuntimeTargetGate.tsx
+++ b/fluxer_app/src/features/auth/flow/AuthRuntimeTargetGate.tsx
@@ -27,6 +27,7 @@ export const AuthRuntimeTargetGate = observer(function AuthRuntimeTargetGate({ch
return (
<AuthLoginInstanceStep
extraTopContent={null}
+ showTitle={true}
title={i18n._(CHOOSE_INSTANCE_DESCRIPTOR)}
initialInstanceUrl={null}
onContinue={runtimeTarget.select}
diff --git a/fluxer_app/src/features/auth/flow/AuthSurfaceTransition.tsx b/fluxer_app/src/features/auth/flow/AuthSurfaceTransition.tsx
index 512adf204..a5e5037a2 100644
--- a/fluxer_app/src/features/auth/flow/AuthSurfaceTransition.tsx
+++ b/fluxer_app/src/features/auth/flow/AuthSurfaceTransition.tsx
@@ -22,7 +22,6 @@ interface AuthSurfaceTransitionProps {
surfaceKey: string;
motionKind: AuthSurfaceMotionKind;
suppressed: boolean;
- anchorsContentOnInteraction: boolean;
className: string;
children: ReactNode;
}
@@ -37,28 +36,10 @@ function setSurfaceFinalStyle(surface: HTMLElement): void {
surface.style.transform = 'translateY(0px) scale(1)';
}
-function anchorSurfaceContent(surface: HTMLElement): void {
- const content = surface.firstElementChild;
- if (surface.style.paddingTop !== '' || !(content instanceof HTMLElement)) {
- return;
- }
- const style = getComputedStyle(surface);
- const paddingTop = Number.parseFloat(style.paddingTop);
- const freeHeight = surface.clientHeight - paddingTop - Number.parseFloat(style.paddingBottom) - content.offsetHeight;
- surface.style.alignItems = 'start';
- surface.style.paddingTop = `${paddingTop + Math.max(0, freeHeight / 2)}px`;
-}
-
-function releaseSurfaceContent(surface: HTMLElement): void {
- surface.style.removeProperty('align-items');
- surface.style.removeProperty('padding-top');
-}
-
export function AuthSurfaceTransition({
surfaceKey,
motionKind,
suppressed,
- anchorsContentOnInteraction,
className,
children,
}: AuthSurfaceTransitionProps) {
@@ -68,7 +49,6 @@ export function AuthSurfaceTransition({
useLayoutEffect(() => {
const surface = surfaceRef.current;
if (surface == null) return;
- releaseSurfaceContent(surface);
if (suppressed) {
setSurfaceFinalStyle(surface);
return;
@@ -91,23 +71,6 @@ export function AuthSurfaceTransition({
animation.revert();
};
}, [motionKind, prefersReducedMotion, suppressed, surfaceKey]);
- useLayoutEffect(() => {
- const surface = surfaceRef.current;
- if (surface == null || suppressed || !anchorsContentOnInteraction) {
- return;
- }
- const anchor = (): void => anchorSurfaceContent(surface);
- const release = (): void => releaseSurfaceContent(surface);
- surface.addEventListener('pointerdown', anchor, true);
- surface.addEventListener('keydown', anchor, true);
- window.addEventListener('resize', release);
- return () => {
- surface.removeEventListener('pointerdown', anchor, true);
- surface.removeEventListener('keydown', anchor, true);
- window.removeEventListener('resize', release);
- release();
- };
- }, [anchorsContentOnInteraction, suppressed]);
return (
<flx-auth-surface-transition
ref={surfaceRef}
diff --git a/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginBrowserStep.tsx b/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginBrowserStep.tsx
index f91fbd627..ee1424e4d 100644
--- a/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginBrowserStep.tsx
+++ b/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginBrowserStep.tsx
@@ -32,6 +32,7 @@ import {Button, ButtonVariant} from '@app/features/ui/button/Button';
import {VerifiedConnectionIcon} from '@app/features/ui/components/icons/VerifiedConnectionIcon';
import {Spinner, SpinnerSize} from '@app/features/ui/components/Spinner';
import FocusRing from '@app/features/ui/focus_ring/FocusRing';
+import {ArrowLeftIcon} from '@app/features/ui/icons/DirectionalIcons';
import {SteppedCarousel, SteppedCarouselActions} from '@app/features/ui/stepped_carousel/SteppedCarousel';
import {isDesktop} from '@app/features/ui/utils/NativeUtils';
import {flxElementClassName} from '@app/lib/react';
@@ -41,7 +42,6 @@ import {msg} from '@lingui/core/macro';
import {Trans, useLingui} from '@lingui/react/macro';
import {
ArrowClockwiseIcon,
- ArrowLeftIcon,
ArrowSquareOutIcon,
CheckCircleIcon,
ClipboardIcon,
@@ -163,44 +163,56 @@ interface WaitingContentProps {
function WaitingContent({handoff, instanceName, onOtherDevice}: WaitingContentProps): ReactElement {
const {i18n} = useLingui();
const showCode = handoff.returnMethod === DesktopHandoffReturnMethod.CODE && handoff.hasCode;
+ const panelClassName = flxElementClassName(styles.browserStatusPanel);
+ const statusIcon = handoff.hasStoppedWaiting ? (
+ <WarningCircleIcon
+ size={remFromPx(28)}
+ weight="regular"
+ data-flx="auth.flow.auth-login-core.auth-login-browser-step.stopped-waiting-icon"
+ />
+ ) : (
+ <Spinner size={SpinnerSize.MEDIUM} data-flx="auth.flow.auth-login-core.auth-login-browser-step.spinner" />
+ );
+ const title = (
+ <flx-auth-login-browser-step-status-title
+ className={flxElementClassName(styles.browserStatusTitle)}
+ data-flx="auth.flow.auth-login-core.auth-login-browser-step.waiting-title"
+ >
+ <Trans comment="Title in the desktop app while it waits for the user to sign in on the browser page it opened.">
+ Continue in your browser
+ </Trans>
+ </flx-auth-login-browser-step-status-title>
+ );
+ const textClassName = flxElementClassName(styles.browserStatusText);
+ let statusText: ReactNode;
+ if (handoff.hasStoppedWaiting) {
+ statusText = i18n._(BROWSER_WAIT_STOPPED_DESCRIPTOR);
+ } else if (showCode) {
+ statusText = (
+ <Trans comment="Shown in the desktop app above the code when the browser cannot return the sign-in automatically. instanceName is the server name, such as Fluxer.">
+ Sign in to {instanceName} in your browser, and check that it shows this code:
+ </Trans>
+ );
+ } else {
+ statusText = (
+ <Trans comment="Shown in the desktop app while it waits for the browser. instanceName is the server name, such as Fluxer.">
+ Sign in to {instanceName} in your browser and confirm. This app finishes signing in on its own.
+ </Trans>
+ );
+ }
return (
<flx-auth-login-browser-step-status-panel
- className={flxElementClassName(styles.browserStatusPanel)}
+ className={panelClassName}
data-flx="auth.flow.auth-login-core.auth-login-browser-step.waiting-panel"
>
- {handoff.hasStoppedWaiting ? (
- <WarningCircleIcon
- size={remFromPx(28)}
- weight="regular"
- data-flx="auth.flow.auth-login-core.auth-login-browser-step.stopped-waiting-icon"
- />
- ) : (
- <Spinner size={SpinnerSize.MEDIUM} data-flx="auth.flow.auth-login-core.auth-login-browser-step.spinner" />
- )}
- <flx-auth-login-browser-step-status-title
- className={flxElementClassName(styles.browserStatusTitle)}
- data-flx="auth.flow.auth-login-core.auth-login-browser-step.waiting-title"
- >
- <Trans comment="Title in the desktop app while it waits for the user to sign in on the browser page it opened.">
- Continue in your browser
- </Trans>
- </flx-auth-login-browser-step-status-title>
+ {statusIcon}
+ {title}
<flx-auth-login-browser-step-status-text
- className={flxElementClassName(styles.browserStatusText)}
+ className={textClassName}
role="status"
data-flx="auth.flow.auth-login-core.auth-login-browser-step.waiting-text"
>
- {handoff.hasStoppedWaiting ? (
- i18n._(BROWSER_WAIT_STOPPED_DESCRIPTOR)
- ) : showCode ? (
- <Trans comment="Shown in the desktop app above the code when the browser cannot return the sign-in automatically. instanceName is the server name, such as Fluxer.">
- Sign in to {instanceName} in your browser, and check that it shows this code:
- </Trans>
- ) : (
- <Trans comment="Shown in the desktop app while it waits for the browser. instanceName is the server name, such as Fluxer.">
- Sign in to {instanceName} in your browser and confirm. This app finishes signing in on its own.
- </Trans>
- )}
+ {statusText}
</flx-auth-login-browser-step-status-text>
{showCode && !handoff.hasStoppedWaiting ? (
<HandoffCode
@@ -326,6 +338,7 @@ interface AuthLoginBrowserStepProps {
readonly onChangeInstance: (() => void) | null;
readonly onSuccess: (payload: LoginSuccessPayload) => Promise<void> | void;
readonly showBackButton?: boolean;
+ readonly startSso?: boolean;
}
export const AuthLoginBrowserStep = observer(function AuthLoginBrowserStep({
@@ -339,6 +352,7 @@ export const AuthLoginBrowserStep = observer(function AuthLoginBrowserStep({
onChangeInstance,
onSuccess,
showBackButton = true,
+ startSso = false,
}: AuthLoginBrowserStepProps) {
const {i18n} = useLingui();
const [step, setStep] = useState<BrowserHandoffStep>(BrowserHandoffStep.WAITING);
@@ -351,6 +365,7 @@ export const AuthLoginBrowserStep = observer(function AuthLoginBrowserStep({
const handoff = useBrowserLoginHandoff({
runtimeSnapshot,
prefillIdentifier,
+ startSso,
onEnded: handleEnded,
onSuccess,
});
@@ -623,12 +638,14 @@ export const AuthLoginBrowserStep = observer(function AuthLoginBrowserStep({
</span>
) : null}
</span>
- <span
- className={styles.browserInstanceDomain}
- data-flx="auth.flow.auth-login-core.auth-login-browser-step.browser-instance-domain"
- >
- {instanceIdentity.domain}
- </span>
+ {instanceIdentity.name === instanceDomainHost(instanceIdentity.domain) ? null : (
+ <span
+ className={styles.browserInstanceDomain}
+ data-flx="auth.flow.auth-login-core.auth-login-browser-step.browser-instance-domain"
+ >
+ {instanceIdentity.domain}
+ </span>
+ )}
</span>
</flx-auth-login-browser-step-instance-identity>
{onChangeInstance == null ? null : (
diff --git a/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginInstanceStep.tsx b/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginInstanceStep.tsx
index d5981ba91..a91673161 100644
--- a/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginInstanceStep.tsx
+++ b/fluxer_app/src/features/auth/flow/auth_login_core/AuthLoginInstanceStep.tsx
@@ -18,6 +18,7 @@ function hasDesktopAppStore(): boolean {
interface AuthLoginInstanceStepProps {
readonly extraTopContent: ReactNode;
+ readonly showTitle: boolean;
readonly title: ReactNode;
readonly initialInstanceUrl: string | null;
readonly onContinue: (snapshot: RuntimeConfigSnapshot) => void;
@@ -27,6 +28,7 @@ interface AuthLoginInstanceStepProps {
export function AuthLoginInstanceStep({
extraTopContent,
+ showTitle,
title,
initialInstanceUrl,
onContinue,
@@ -39,9 +41,11 @@ export function AuthLoginInstanceStep({
data-flx="auth.flow.auth-login-core.auth-login-instance-step.flx-element"
>
{extraTopContent}
- <h1 className={loginStyles.title} data-flx="auth.flow.auth-login-core.auth-login-instance-step.h1">
- {title}
- </h1>
+ {showTitle ? (
+ <h1 className={loginStyles.title} data-flx="auth.flow.auth-login-core.auth-login-instance-step.h1">
+ {title}
+ </h1>
+ ) : null}
<flx-auth-login-instance-step-body
className={flxElementClassName(styles.inlineStep)}
data-flx="auth.flow.auth-login-core.auth-login-instance-step.inline-step"