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

Added support for updating subscription by id

no-issue

The Admin API uses a Member id rather than email to update
subscriptions, this ensures that we provide an interface that will
continue to work with the Admin API
This commit is contained in:
Fabien O'Carroll 2021-03-30 11:00:39 +01:00
parent e2a46863d8
commit 999acc60d7

View file

@ -424,9 +424,18 @@ module.exports = class MemberRepository {
throw new Error('Cannot update Stripe Subscription with no Stripe Connection');
}
const member = await this._Member.findOne({
email: data.email
});
let findQuery = null;
if (data.id) {
findQuery = {id: data.id};
} else if (data.email) {
findQuery = {email: data.email};
}
if (!findQuery) {
throw new Error('Cannot update Subscription without an id or email for the Member');
}
const member = await this._Member.findOne(findQuery);
const subscription = await member.related('stripeSubscriptions').query({
where: {