test(auth): cover PSID external entry login
This commit is contained in:
@@ -44,6 +44,7 @@ export default function ExternalEntryPersist({
|
||||
const authDispatch = useAuthDispatch();
|
||||
const [hasPersisted, setHasPersisted] = useState(false);
|
||||
const hasNavigatedRef = useRef(false);
|
||||
const hasReinitializedForPsidRef = useRef(false);
|
||||
const targetRoute = resolveExternalEntryTarget({ target });
|
||||
const destination = resolveExternalEntryDestination({ target });
|
||||
const resolvedPromotionType = resolveExternalEntryPromotionType({
|
||||
@@ -94,6 +95,16 @@ export default function ExternalEntryPersist({
|
||||
|
||||
useEffect(() => {
|
||||
if (hasNavigatedRef.current || !hasPersisted) return;
|
||||
|
||||
// AuthStatusChecker can initialize before this entry has persisted PSID.
|
||||
// Re-run the check so PSID direct login is not skipped by that race.
|
||||
if (hasValue(psid) && !hasReinitializedForPsidRef.current) {
|
||||
if (!authState.hasInitialized || authState.isLoading) return;
|
||||
hasReinitializedForPsidRef.current = true;
|
||||
authDispatch({ type: "AuthInit" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!authState.hasInitialized || authState.isLoading) return;
|
||||
hasNavigatedRef.current = true;
|
||||
|
||||
@@ -138,3 +149,7 @@ export default function ExternalEntryPersist({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function hasValue(value: string | null): value is string {
|
||||
return typeof value === "string" && value.trim().length > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user