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:
parent
b84e54b0cf
commit
aaff165a21
1 changed files with 6 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue