From db105dc28e40f0cb7133194e1113d41f572ac8c8 Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Wed, 24 Jul 2024 16:54:13 -0400 Subject: [PATCH] fix(ras-acc): correctly update myaccount link after signing in (#3271) This PR ensures we are always updating the RAS-ACC my account button URL after successfully signing in or creating an account. --- assets/reader-activation-auth/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/assets/reader-activation-auth/index.js b/assets/reader-activation-auth/index.js index f536a67422..8743adca88 100644 --- a/assets/reader-activation-auth/index.js +++ b/assets/reader-activation-auth/index.js @@ -59,13 +59,10 @@ window.newspackRAS.push( readerActivation => { } } } - if ( redirect !== '#' ) { + if ( redirect && redirect !== '#' ) { callback = () => { window.location.href = redirect; }; - } else { - // Set account URL after logging in. - ev.target.href = newspack_ras_config.account_url; } openAuthModal( { callback } ); } @@ -97,6 +94,11 @@ window.newspackRAS.push( readerActivation => { const labelEl = link.querySelector( '.newspack-reader__account-link__label' ); if ( labelEl ) { labelEl.textContent = reader?.authenticated ? labels.signedin : labels.signedout; + + // Set my account link href if the reader is authenticated. + if ( reader?.authenticated ) { + link.setAttribute( 'href', newspack_ras_config.account_url ); + } } } ); }