Skip to content

Commit c943c3d

Browse files
committed
fix: remove paywall - snow leopard is free!!
1 parent f900bb8 commit c943c3d

File tree

1 file changed

+24
-44
lines changed

1 file changed

+24
-44
lines changed

apps/snow-leopard/lib/auth.ts

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use client';
12
import 'server-only';
23
import { betterAuth } from 'better-auth';
34
import { drizzleAdapter } from "better-auth/adapters/drizzle";
@@ -18,12 +19,11 @@ if (!process.env.BETTER_AUTH_URL) {
1819
throw new Error('Missing BETTER_AUTH_URL environment variable');
1920
}
2021

21-
if (process.env.STRIPE_ENABLED === 'true') {
22-
if (!process.env.STRIPE_SECRET_KEY) throw new Error('Missing STRIPE_SECRET_KEY but STRIPE_ENABLED is true');
23-
if (!process.env.STRIPE_WEBHOOK_SECRET) throw new Error('Missing STRIPE_WEBHOOK_SECRET but STRIPE_ENABLED is true');
24-
if (!process.env.STRIPE_PRO_MONTHLY_PRICE_ID) throw new Error('Missing STRIPE_PRO_MONTHLY_PRICE_ID but STRIPE_ENABLED is true'); // Example Price ID env var
25-
if (!process.env.STRIPE_PRO_YEARLY_PRICE_ID) throw new Error('Missing STRIPE_PRO_YEARLY_PRICE_ID but STRIPE_ENABLED is true'); // Add check for yearly price ID
26-
}
22+
// Unconditional Stripe key checks
23+
if (!process.env.STRIPE_SECRET_KEY) throw new Error('Missing STRIPE_SECRET_KEY');
24+
if (!process.env.STRIPE_WEBHOOK_SECRET) throw new Error('Missing STRIPE_WEBHOOK_SECRET');
25+
if (!process.env.STRIPE_PRO_MONTHLY_PRICE_ID) throw new Error('Missing STRIPE_PRO_MONTHLY_PRICE_ID');
26+
if (!process.env.STRIPE_PRO_YEARLY_PRICE_ID) throw new Error('Missing STRIPE_PRO_YEARLY_PRICE_ID');
2727

2828
const emailVerificationEnabled = process.env.EMAIL_VERIFY_ENABLED === 'true';
2929
console.log(`Email Verification Enabled: ${emailVerificationEnabled}`);
@@ -66,24 +66,19 @@ console.log('BETTER_AUTH_SECRET:', process.env.BETTER_AUTH_SECRET ? 'Set' : 'MIS
6666
console.log('BETTER_AUTH_URL:', process.env.BETTER_AUTH_URL ? 'Set' : 'MISSING!');
6767
console.log('-----------------------------------------\n'); // Added newline for clarity
6868

69-
70-
const stripeClient = process.env.STRIPE_ENABLED === 'true' && process.env.STRIPE_SECRET_KEY
71-
? new Stripe(process.env.STRIPE_SECRET_KEY, { apiVersion: "2025-02-24.acacia" })
72-
: null;
73-
69+
const stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY, { apiVersion: "2025-02-24.acacia" });
7470

7571
const resend = emailVerificationEnabled && process.env.RESEND_API_KEY
7672
? new Resend(process.env.RESEND_API_KEY)
7773
: null;
7874

79-
const plans = process.env.STRIPE_ENABLED === 'true' ? [
75+
const plans = [
8076
{
81-
name: "snowleopard",
82-
priceId: process.env.STRIPE_PRO_MONTHLY_PRICE_ID!,
83-
annualDiscountPriceId: process.env.STRIPE_PRO_YEARLY_PRICE_ID!,
84-
// freeTrial is now handled via a separate onboarding flow
77+
name: "snowleopard",
78+
priceId: process.env.STRIPE_PRO_MONTHLY_PRICE_ID!,
79+
annualDiscountPriceId: process.env.STRIPE_PRO_YEARLY_PRICE_ID!,
8580
},
86-
] : [];
81+
];
8782

8883
type HookUser = {
8984
id: string;
@@ -92,33 +87,18 @@ type HookUser = {
9287

9388
const authPlugins: any[] = [];
9489

95-
if (process.env.STRIPE_ENABLED === 'true') {
96-
console.log('Stripe is ENABLED. Adding Stripe plugin to Better Auth.');
97-
if (!stripeClient) {
98-
throw new Error('STRIPE_ENABLED is true, but STRIPE_SECRET_KEY is missing or Stripe client failed to initialize.');
99-
}
100-
if (!process.env.STRIPE_WEBHOOK_SECRET) {
101-
throw new Error('STRIPE_ENABLED is true, but STRIPE_WEBHOOK_SECRET is missing.');
102-
}
103-
if (plans.length === 0 || !process.env.STRIPE_PRO_MONTHLY_PRICE_ID || !process.env.STRIPE_PRO_YEARLY_PRICE_ID) {
104-
throw new Error('STRIPE_ENABLED is true, but required Stripe Price IDs (Monthly/Yearly) are missing or plans array is misconfigured.');
105-
}
106-
107-
authPlugins.push(
108-
stripe({
109-
stripeClient,
110-
stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
111-
createCustomerOnSignUp: true,
112-
subscription: {
113-
enabled: true,
114-
plans: plans,
115-
requireEmailVerification: true,
116-
},
117-
})
118-
);
119-
} else {
120-
console.log('Stripe is DISABLED. Skipping Stripe plugin for Better Auth.');
121-
}
90+
authPlugins.push(
91+
stripe({
92+
stripeClient,
93+
stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
94+
createCustomerOnSignUp: true,
95+
subscription: {
96+
enabled: process.env.STRIPE_ENABLED === 'true',
97+
plans,
98+
requireEmailVerification: emailVerificationEnabled,
99+
},
100+
})
101+
);
122102

123103
authPlugins.push(nextCookies());
124104

0 commit comments

Comments
 (0)