🪻 distributed transcription service thistle.dunkirk.sh
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: cancel user subscription on account delete

+9 -6
+1 -1
src/components/user-settings.ts
··· 587 587 588 588 async handleDeleteAccount() { 589 589 try { 590 - const response = await fetch("/api/auth/delete-account", { 590 + const response = await fetch("/api/user", { 591 591 method: "DELETE", 592 592 }); 593 593
+8 -5
src/lib/auth.ts
··· 190 190 ) 191 191 .get(userId); 192 192 193 - // Revoke subscription if it exists 193 + // Cancel subscription if it exists (soft cancel - keeps access until period end) 194 194 if (subscription) { 195 195 try { 196 196 const { polar } = await import("./polar"); 197 - await polar.subscriptions.revoke({ id: subscription.id }); 197 + await polar.subscriptions.update({ 198 + id: subscription.id, 199 + subscriptionUpdate: { cancelAtPeriodEnd: true }, 200 + }); 198 201 console.log( 199 - `[User Delete] Revoked subscription ${subscription.id} for user ${userId}`, 202 + `[User Delete] Canceled subscription ${subscription.id} for user ${userId}`, 200 203 ); 201 204 } catch (error) { 202 205 console.error( 203 - `[User Delete] Failed to revoke subscription ${subscription.id}:`, 206 + `[User Delete] Failed to cancel subscription ${subscription.id}:`, 204 207 error, 205 208 ); 206 - // Continue with user deletion even if subscription revocation fails 209 + // Continue with user deletion even if subscription cancellation fails 207 210 } 208 211 } 209 212