diff --git a/src/reader-activation-auth/index.js b/src/reader-activation-auth/index.js index 9a159f3584..831ba8e3e7 100644 --- a/src/reader-activation-auth/index.js +++ b/src/reader-activation-auth/index.js @@ -47,6 +47,10 @@ window.newspackRAS.push( readerActivation => { ev.preventDefault(); const modalTrigger = ev.target; let callback, redirect; + + // Check ancestors to see if we're signing in to an existing account. + const isExistingAccountFlow = Boolean( modalTrigger.closest( '.newspack-registration__have-account' ) ); + if ( ev.target.getAttribute( 'data-redirect' ) ) { redirect = ev.target.getAttribute( 'data-redirect' ); } else { @@ -62,7 +66,9 @@ window.newspackRAS.push( readerActivation => { } } } - if ( redirect && redirect !== '#' ) { + + // If we're in a modal, ignore redirect so 'Continue' dismisses it and reader can continue on the current page. + if ( redirect && redirect !== '#' && ! isExistingAccountFlow ) { callback = () => { window.location.href = redirect; };