mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-03-15 13:25:57 +00:00
fix: check db initialisation on getOrCreateCloudUser
This commit is contained in:
@@ -41,10 +41,6 @@ export default async function CloudPaymentSuccessPage({
|
||||
aiBalance: plan?.limits.ai,
|
||||
})
|
||||
|
||||
if (await isDatabaseEmpty(user.id)) {
|
||||
await createUserDefaults(user.id)
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="w-full max-w-xl mx-auto p-8 flex flex-col items-center justify-center gap-4">
|
||||
<Cake className="w-36 h-36" />
|
||||
|
||||
@@ -86,16 +86,12 @@ async function handleUserSubscriptionUpdate(
|
||||
if (!user) {
|
||||
const customer = (await stripeClient.customers.retrieve(customerId)) as Stripe.Customer
|
||||
console.log(`User not found for customer ${customerId}, creating new user with email ${customer.email}`)
|
||||
|
||||
|
||||
user = await getOrCreateCloudUser(customer.email as string, {
|
||||
email: customer.email as string,
|
||||
name: customer.name as string,
|
||||
stripeCustomerId: customer.id,
|
||||
})
|
||||
|
||||
if (await isDatabaseEmpty(user.id)) {
|
||||
await createUserDefaults(user.id)
|
||||
}
|
||||
}
|
||||
|
||||
const newMembershipExpiresAt = new Date(item.current_period_end * 1000)
|
||||
|
||||
Reference in New Issue
Block a user