mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Fixed direct subscribe links broken
refs https://github.com/TryGhost/Product/issues/3770 - Site is not always defined, so the things broke when using the signup action without a defined site, where it wants to read the recommendations_enabled setting - Fixed this by removing the welcome page and looking for the existing query params instead
This commit is contained in:
parent
9e45afddb8
commit
d1c6bfefbc
3 changed files with 26 additions and 19 deletions
|
@ -426,6 +426,18 @@ export default class App extends React.Component {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (hasRecommendations({site}) && qParams.get('action') === 'signup' && qParams.get('success') === 'true') {
|
||||
// After a successful signup, we show the recommendations if they are enabled
|
||||
return {
|
||||
showPopup: true,
|
||||
page: 'recommendations',
|
||||
pageData: {
|
||||
signup: true
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const [path, hashQueryString] = window.location.hash.substr(1).split('?');
|
||||
const hashQuery = new URLSearchParams(hashQueryString ?? '');
|
||||
const productMonthlyPriceQueryRegex = /^(?:(\w+?))?\/monthly$/;
|
||||
|
@ -801,13 +813,6 @@ export default class App extends React.Component {
|
|||
signup: false
|
||||
}
|
||||
};
|
||||
} else if (path === 'welcome' && hasRecommendations({site})) {
|
||||
return {
|
||||
page: 'recommendations',
|
||||
pageData: {
|
||||
signup: true
|
||||
}
|
||||
};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -96,25 +96,16 @@ async function signin({data, api, state}) {
|
|||
|
||||
async function signup({data, state, api}) {
|
||||
try {
|
||||
const {recommendations_enabled: recommendationsEnabled = false} = state.site;
|
||||
const {recommendations = []} = state.site;
|
||||
let successUrl = undefined;
|
||||
|
||||
if (recommendationsEnabled && recommendations.length > 0) {
|
||||
const currentUrl = window.location.origin + window.location.pathname;
|
||||
successUrl = `${currentUrl}#/portal/welcome`;
|
||||
}
|
||||
|
||||
let {plan, tierId, cadence, email, name, newsletters, offerId} = data;
|
||||
|
||||
if (plan.toLowerCase() === 'free') {
|
||||
await api.member.sendMagicLink({emailType: 'signup', ...data, redirect: successUrl});
|
||||
await api.member.sendMagicLink({emailType: 'signup', ...data});
|
||||
} else {
|
||||
if (tierId && cadence) {
|
||||
await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId, successUrl});
|
||||
await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId});
|
||||
} else {
|
||||
({tierId, cadence} = getProductCadenceFromPrice({site: state?.site, priceId: plan}));
|
||||
await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId, successUrl});
|
||||
await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId});
|
||||
}
|
||||
return {
|
||||
page: 'loading'
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import AppContext from '../../AppContext';
|
||||
import {useContext, useState, useEffect} from 'react';
|
||||
import CloseButton from '../common/CloseButton';
|
||||
import {clearURLParams} from '../../utils/notifications';
|
||||
|
||||
export const RecommendationsPageStyles = `
|
||||
.gh-portal-recommendation-item .gh-portal-list-detail {
|
||||
|
@ -88,6 +89,16 @@ const RecommendationsPage = () => {
|
|||
setNumToShow(recommendations.length);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (pageData.signup) {
|
||||
const deleteParams = [];
|
||||
deleteParams.push('action', 'success');
|
||||
clearURLParams(deleteParams);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
const heading = pageData && pageData.signup ? t('You\'re subscribed!') : t('Recommendations');
|
||||
const subheading = t(`Here are a few other sites {{siteTitle}} thinks you may enjoy.`, {siteTitle: title});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue