Updated members allowSelfSignup() to take portal plans into account (#12909)

refs https://github.com/TryGhost/Team/issues/579

`members_signup_access = 'invite'` now forces invite-only mode so both free and paid setups both use the `'all'` setting. To ensure we're properly allowing/disabling free (self signup) signups in the members API we need to update `allowSelfSignup()` to take additional settings into account.

- `true` when Stripe is not connected. There are no paid plans available in this configuration so free signup is always enabled. To disable free signup on a site with no Stripe setup the members signup access should be set to `invite` or `none`.
- `true` when Stripe is configured and free plan is enabled in portal, without it Members API would not send magic link emails to signup requests
- `false` in all other situations such as invite-only and members-disabled signup access modes, or when the free plan has been disabled in portal configuration
This commit is contained in:
Kevin Ansfield 2021-04-27 16:22:43 +01:00 committed by GitHub
parent 10b6fbfc82
commit cf29ed8c30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -215,7 +215,25 @@ class MembersConfigProvider {
}
getAllowSelfSignup() {
return this._settingsCache.get('members_signup_access') === 'all';
// 'invite' and 'none' members signup access disables all signup
if (this._settingsCache.get('members_signup_access') !== 'all') {
return false;
}
// if stripe is not connected then selected plans mean nothing.
// disabling signup would be done by switching to "invite only" mode
if (!this.isStripeConnected()) {
return true;
}
// self signup must be available for free plan signup to work
const hasFreePlan = this._settingsCache.get('portal_plans').includes('free');
if (hasFreePlan) {
return true;
}
// signup access is enabled but there's no free plan, don't allow self signup
return false;
}
getTokenConfig() {