Fixed signup with email not working on free plan

closes https://github.com/TryGhost/members.js/issues/16

This fix sends magic link to member when they choose free plan to signup using name and email.

Note: We are not storing `name` atm in magic link, so it gets ignored in actual member data on signup atm.
This commit is contained in:
Rish 2020-04-23 21:18:34 +05:30
parent 1fdc514c1f
commit c44241e27d
2 changed files with 19 additions and 13 deletions

View File

@ -138,6 +138,18 @@ export default class ParentContainer extends React.Component {
}); });
} }
if (action === 'signup') {
await this.MembersAPI.member.sendMagicLink(data);
this.setState({
action: {
name: action,
isRunning: false,
isSuccess: true
},
page: 'magiclink'
});
}
if (action === 'checkoutPlan') { if (action === 'checkoutPlan') {
const checkoutSuccessUrl = (new URL('/account/?stripe=billing-update-success', window.location.href)).href; const checkoutSuccessUrl = (new URL('/account/?stripe=billing-update-success', window.location.href)).href;
const checkoutCancelUrl = (new URL('/account/?stripe=billing-update-cancel', window.location.href)).href; const checkoutCancelUrl = (new URL('/account/?stripe=billing-update-cancel', window.location.href)).href;

View File

@ -24,22 +24,12 @@ export default class SignupPage extends React.Component {
}; };
} }
handleSignin(e) { handleSignup(e) {
e.preventDefault(); e.preventDefault();
const email = this.state.email; const email = this.state.email;
const name = this.state.name; const name = this.state.name;
const plan = this.state.plan; const plan = this.state.plan;
this.props.onAction('signup', {name, email, plan}); this.props.onAction('signup', {name, email, plan});
this.setState({
isLoading: true,
showSuccess: false
});
setTimeout(() => {
this.setState({
isLoading: false,
showSuccess: true
});
}, 3000);
} }
handleInput(e, field) { handleInput(e, field) {
@ -72,11 +62,15 @@ export default class SignupPage extends React.Component {
width: '100%', width: '100%',
marginBottom: '12px' marginBottom: '12px'
}; };
const isRunning = this.props.action && this.props.action.name === 'signup' && this.props.action.isRunning;
const label = this.state.isLoading ? 'Sending' : 'Continue'; const label = this.state.isLoading ? 'Sending' : 'Continue';
const disabled = this.state.isLoading ? true : false; const disabled = isRunning ? true : false;
if (disabled) {
buttonStyle.backgroundColor = 'grey';
}
return ( return (
<button onClick={(e) => { <button onClick={(e) => {
this.handleSignin(e); this.handleSignup(e);
}} style={buttonStyle} disabled={disabled}> }} style={buttonStyle} disabled={disabled}>
{label} {label}
</button> </button>