mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
fix issue where subs would be applied multiple times
This commit is contained in:
committed by
Phillip Thelen
parent
cf75d941fa
commit
0dd25b6431
@@ -124,12 +124,16 @@ api.subscribe = async function subscribe (sku, user, receipt, headers, nextPayme
|
||||
throw new NotAuthorized(this.constants.RESPONSE_ALREADY_USED);
|
||||
}
|
||||
existingSub = shared.content.subscriptionBlocks[user.purchased.plan.planId];
|
||||
if (existingSub === sub) {
|
||||
throw new NotAuthorized(this.constants.RESPONSE_ALREADY_USED);
|
||||
}
|
||||
}
|
||||
const existingUser = await User.findOne({
|
||||
'purchased.plan.customerId': originalTransactionId,
|
||||
}).exec();
|
||||
if (existingUser
|
||||
&& (originalTransactionId === newTransactionId || existingUser._id !== user._id)) {
|
||||
&& (originalTransactionId === newTransactionId
|
||||
|| existingUser._id !== user._id)) {
|
||||
throw new NotAuthorized(this.constants.RESPONSE_ALREADY_USED);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user