;
+ onContinueWithGoogle?: () => void;
+ onContinueWithApple?: () => void;
showSeparator?: boolean;
viewName?: string;
flowQueryParams?: QueryParams;
@@ -73,16 +73,16 @@ const ThirdPartyAuth = ({
>
)}
-
@@ -91,17 +91,17 @@ const ThirdPartyAuth = ({
),
}}
/>
-
@@ -116,15 +116,9 @@ const ThirdPartyAuth = ({
);
};
-/**
- * Represents the sign in form posted to google third party auth.
- * Note that the innerRef is used by the parent component to trigger
- * a form submission.
- */
-const ThirdPartySignInForm = ({
+const ThirdPartySignInButton = ({
party,
authorizationEndpoint,
- state,
clientId,
scope,
redirectUri,
@@ -139,7 +133,6 @@ const ThirdPartySignInForm = ({
}: {
party: 'google' | 'apple';
authorizationEndpoint: string;
- state: string;
clientId: string;
scope: string;
redirectUri: string;
@@ -148,14 +141,12 @@ const ThirdPartySignInForm = ({
responseType: string;
responseMode?: string;
buttonText: ReactElement;
- onSubmit?: FormEventHandler;
+ onSubmit?: () => void;
viewName?: string;
flowQueryParams?: QueryParams;
}) => {
const { logViewEventOnce } = useMetrics();
const { l10n } = useLocalization();
- const stateRef = useRef(null);
- const formRef = useRef(null);
const getLoginAriaLabel = () => {
const labels = {
@@ -173,7 +164,8 @@ const ThirdPartySignInForm = ({
return labels[party];
};
- const onClick = useCallback(async () => {
+ const handleClick = useCallback(async () => {
+ onSubmit?.();
logViewEventOnce(`flow.${party}`, 'oauth-start');
switch (`${party}-${viewName}`) {
case 'google-index':
@@ -196,57 +188,51 @@ const ThirdPartySignInForm = ({
break;
}
- // wait for all the Glean events to be sent before the page unloads
+ // Wait for all Glean events to be sent before navigating away.
await GleanMetrics.isDone();
- if (stateRef.current) {
- stateRef.current.value = getState(flowQueryParams);
- }
- }, [party, stateRef, viewName, logViewEventOnce, flowQueryParams]);
-
- if (onSubmit === undefined) {
- onSubmit = () => true;
- }
+ const params = {
+ state: getState(flowQueryParams),
+ client_id: clientId,
+ scope,
+ redirect_uri: redirectUri,
+ access_type: accessType,
+ prompt,
+ response_type: responseType,
+ ...(responseMode ? { response_mode: responseMode } : {}),
+ };
+ hardNavigate(authorizationEndpoint, params, false, false, 0);
+ }, [
+ party,
+ viewName,
+ logViewEventOnce,
+ flowQueryParams,
+ clientId,
+ scope,
+ redirectUri,
+ accessType,
+ prompt,
+ responseType,
+ responseMode,
+ authorizationEndpoint,
+ onSubmit,
+ ]);
return (
-
+ {buttonText}
+
);
};