Skip to content

Commit

Permalink
fix: prevent duplicate app deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
johackim committed Jun 14, 2023
1 parent 44ab69a commit d177725
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pages/api/users.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dotenv/config';
import bcrypt from 'bcrypt';
import { Op } from '@lib/orm';
import { protectRoute, sendWebhook, isValidPassword } from '@lib/utils';
import { upsertCustomer, getCustomerSubscriptions, deleteSubscription } from '@lib/stripe';

Expand All @@ -26,7 +27,7 @@ const putQuery = async (body, res, user) => {

const deleteQuery = async (_, res, user) => {
await user.update({ email: `deleted+${user.email}` }, { where: { id: user.id } });
const apps = await user.getApps({ raw: false });
const apps = await user.getApps({ where: { [Op.not]: { state: 'deleted' } }, raw: false });

const subscriptions = await getCustomerSubscriptions(user.id);

Expand Down

0 comments on commit d177725

Please sign in to comment.