Skip to content

Commit

Permalink
fix(ras-acc): correctly update myaccount link after signing in (#3271)
Browse files Browse the repository at this point in the history
This PR ensures we are always updating the RAS-ACC my account button URL after successfully signing in or creating an account.
  • Loading branch information
chickenn00dle authored Jul 24, 2024
1 parent 5be703b commit db105dc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions assets/reader-activation-auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } );
}
Expand Down Expand Up @@ -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 );
}
}
} );
}
Expand Down

0 comments on commit db105dc

Please sign in to comment.