Establish lock to avoid race scenario in subscriptions (#14267)

* fix(subscription): establish lock to avoid race scenario

* fix(lint): import syntax

* fix(lint): whitespace, dependency cycle

* fix(subs): skip locking on gifts and groups

* fix(subs): correctly reset _subSignature

* fix(sub): use findOneAndUpdate for unlock

* fix(test): save newly created user for some reason

Co-authored-by: SabreCat <sabe@habitica.com>
This commit is contained in:
Sabe Jones
2022-10-25 16:44:33 -05:00
committed by GitHub
parent 22a0c72f6e
commit 90250d1a25
3 changed files with 38 additions and 4 deletions

View File

@@ -326,6 +326,7 @@ describe('Apple Payments', () => {
it('errors when a user is already subscribed', async () => {
payments.createSubscription.restore();
user = new User();
await user.save();
await applePayments.subscribe(sku, user, receipt, headers, nextPaymentProcessing);