0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Fixed 'labels is not defined on the model' error (#378)

no issue

- When a new member is added via the API, with a stripe_customer_id, the member bread service is passed also with a default option: `withRelated: ['labels']`.
- This option is passed along to the member repository, and further and is also passed when loading relations that don't have a relationship called 'labels'.
- This results in a `labels is not defined on the model` error when you try to create a new member with a stripe customer id.
- Test that found this issue will be added to the Ghost repo.
This commit is contained in:
Simon Backx 2022-03-31 16:15:53 +02:00 committed by GitHub
parent b84e54b0cf
commit aaff165a21

View file

@ -220,12 +220,16 @@ module.exports = class MemberBREADService {
throw error;
}
const sharedOptions = options.transacting ? {
transacting: options.transacting
} : {};
try {
if (data.stripe_customer_id) {
await this.memberRepository.linkStripeCustomer({
customer_id: data.stripe_customer_id,
member_id: model.id
}, options);
}, sharedOptions);
}
} catch (error) {
const isStripeLinkingError = error.message && (error.message.match(/customer|plan|subscription/g));
@ -245,7 +249,7 @@ module.exports = class MemberBREADService {
if (!this.labsService.isSet('multipleProducts')) {
if (data.comped) {
await this.memberRepository.setComplimentarySubscription(model, options);
await this.memberRepository.setComplimentarySubscription(model, sharedOptions);
}
}