Skip to content

Commit 8040c3d

Browse files
committed
Refactor auxia isSignedIn check
1 parent 95ca74d commit 8040c3d

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

dotcom-rendering/src/components/SignInGateSelector.importable.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from '../lib/contributions';
77
import { getDailyArticleCount, getToday } from '../lib/dailyArticleCount';
88
import type { EditionId } from '../lib/edition';
9+
import { isUserLoggedInOktaRefactor } from '../lib/identity';
910
import { parseCheckoutCompleteCookieData } from '../lib/parser/parseCheckoutOutCookieData';
1011
import { constructQuery } from '../lib/querystring';
1112
import { useAB } from '../lib/useAB';
@@ -650,12 +651,6 @@ const SignInGateSelectorAuxia = ({
650651
This function if the Auxia prototype for the SignInGateSelector component.
651652
*/
652653

653-
const authStatus = useAuthStatus();
654-
655-
const isSignedIn =
656-
authStatus.kind === 'SignedInWithOkta' ||
657-
authStatus.kind === 'SignedInWithCookies';
658-
659654
const [isGateDismissed, setIsGateDismissed] = useState<boolean | undefined>(
660655
undefined,
661656
);
@@ -689,11 +684,13 @@ const SignInGateSelectorAuxia = ({
689684

690685
useOnce(() => {
691686
void (async () => {
687+
// Only make a request to Auxia if user is signed out. This means signed-in users will never receive an Auxia treatment, and therefore never see a sign-in gate
688+
const isSignedIn = await isUserLoggedInOktaRefactor();
689+
692690
// Although the component is returning null if we are in preview or it's a paid content
693691
// We need to guard against the API possibly being called before the component returns.
694692
// That is because it would count as a content delivery for them, above all if they return a treatment
695693
// without the subsequent Log Treatment notification, which would cause confusion.
696-
697694
if (!isSignedIn && !isPreview && !isPaidContent) {
698695
const data = await buildAuxiaGateDisplayData(
699696
contributionsServiceUrl,
@@ -730,15 +727,15 @@ const SignInGateSelectorAuxia = ({
730727
})().catch((error) => {
731728
console.error('Error fetching Auxia display data:', error);
732729
});
733-
}, [abTest, isSignedIn, isPaidContent, isPreview]);
730+
}, [abTest, isPaidContent, isPreview]);
734731

735732
// We are not showing the gate if we are in preview, it's a paid contents
736733
// or the user is signed in or if for some reasons we could not determine the
737734
// pageViewId
738735

739736
// According to the reacts rules we can only put this check after all the hooks.
740737

741-
if (isPreview || isPaidContent || isSignedIn || isUndefined(pageViewId)) {
738+
if (isPreview || isPaidContent || isUndefined(pageViewId)) {
742739
return null;
743740
}
744741

0 commit comments

Comments
 (0)