Merge pull request #22032 from overleaf/em-subscription-change-preview-404

Handle user without a subscription when asking for a change preview

GitOrigin-RevId: dab90720b292fd0cfb6dbb8a554797b9d2ac436b
This commit is contained in:
Eric Mc Sween
2024-11-25 09:05:06 +00:00
committed by Copybot
parent 838ae23b52
commit b0c309e993
3 changed files with 52 additions and 48 deletions
@@ -547,7 +547,11 @@ async function purchaseAddon(req, res, next) {
logger.debug({ userId: user._id, addOnCode }, 'purchasing add-ons')
try {
await SubscriptionHandler.promises.purchaseAddon(user, addOnCode, quantity)
await SubscriptionHandler.promises.purchaseAddon(
user._id,
addOnCode,
quantity
)
return res.sendStatus(200)
} catch (err) {
if (err instanceof DuplicateAddOnError) {
@@ -580,7 +584,7 @@ async function removeAddon(req, res, next) {
logger.debug({ userId: user._id, addOnCode }, 'removing add-ons')
try {
await SubscriptionHandler.promises.removeAddon(user, addOnCode)
await SubscriptionHandler.promises.removeAddon(user._id, addOnCode)
res.sendStatus(200)
} catch (err) {
if (err instanceof AddOnNotPresentError) {