From 2ada920e4a68caafcc1e40c5b503ac2d24b99c9d Mon Sep 17 00:00:00 2001 From: Aj Wazzan Date: Sat, 9 Aug 2025 11:54:29 -0700 Subject: [PATCH] hotfix --- apps/server/src/lib/auth.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/server/src/lib/auth.ts b/apps/server/src/lib/auth.ts index 4a560b3bd..0d1fa36e1 100644 --- a/apps/server/src/lib/auth.ts +++ b/apps/server/src/lib/auth.ts @@ -21,10 +21,10 @@ import { APIError } from 'better-auth/api'; import { getZeroDB } from './server-utils'; import { type EProviders } from '../types'; import type { HonoContext } from '../ctx'; -import { env } from '../env'; import { createDriver } from './driver'; import { createDb } from '../db'; import { Effect } from 'effect'; +import { env } from '../env'; import { Dub } from 'dub'; const scheduleCampaign = (userInfo: { address: string; name: string }) => @@ -192,11 +192,20 @@ export const createAuth = () => { const db = await getZeroDB(user.id); const connections = await db.findManyConnections(); const context = getContext(); - try { - await context.var.autumn.customers.delete(user.id); - } catch (error) { - console.error('Failed to delete Autumn customer:', error); - // Continue with deletion process despite Autumn failure + const customer = await context.var.autumn.customers.get(user.id); + if (customer.data) { + try { + await Promise.all( + customer.data.products.map(async (product) => + context.var.autumn.cancel({ + customer_id: user.id, + product_id: product.id, + }), + ), + ); + } catch (error) { + console.error('Failed to delete Autumn customer:', error); + } } const revokedAccounts = (