mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
feat(cli): add polar as better-auth plugin (#578)
This commit is contained in:
@@ -4,6 +4,10 @@ import { prismaAdapter } from "better-auth/adapters/prisma";
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
import { expo } from "@better-auth/expo";
|
||||
{{/if}}
|
||||
{{#if (eq payments "polar")}}
|
||||
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
||||
import { polarClient } from "./payments";
|
||||
{{/if}}
|
||||
import prisma from "../db";
|
||||
|
||||
export const auth = betterAuth<BetterAuthOptions>({
|
||||
@@ -28,9 +32,35 @@ export const auth = betterAuth<BetterAuthOptions>({
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
{{#if (eq payments "polar")}}
|
||||
plugins: [
|
||||
polar({
|
||||
client: polarClient,
|
||||
createCustomerOnSignUp: true,
|
||||
enableCustomerPortal: true,
|
||||
use: [
|
||||
checkout({
|
||||
products: [
|
||||
{
|
||||
productId: "your-product-id",
|
||||
slug: "pro",
|
||||
},
|
||||
],
|
||||
successUrl: process.env.POLAR_SUCCESS_URL,
|
||||
authenticatedUsersOnly: true,
|
||||
}),
|
||||
portal(),
|
||||
],
|
||||
}),
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
expo(),
|
||||
{{/if}}
|
||||
],
|
||||
{{else}}
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
, plugins: [expo()]
|
||||
plugins: [expo()],
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
});
|
||||
{{/if}}
|
||||
@@ -42,6 +72,10 @@ import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
import { expo } from "@better-auth/expo";
|
||||
{{/if}}
|
||||
{{#if (eq payments "polar")}}
|
||||
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
||||
import { polarClient } from "./payments";
|
||||
{{/if}}
|
||||
import { db } from "../db";
|
||||
import * as schema from "../db/schema/auth";
|
||||
|
||||
@@ -68,9 +102,35 @@ export const auth = betterAuth<BetterAuthOptions>({
|
||||
httpOnly: true,
|
||||
},
|
||||
},
|
||||
{{#if (eq payments "polar")}}
|
||||
plugins: [
|
||||
polar({
|
||||
client: polarClient,
|
||||
createCustomerOnSignUp: true,
|
||||
enableCustomerPortal: true,
|
||||
use: [
|
||||
checkout({
|
||||
products: [
|
||||
{
|
||||
productId: "your-product-id",
|
||||
slug: "pro",
|
||||
},
|
||||
],
|
||||
successUrl: process.env.POLAR_SUCCESS_URL,
|
||||
authenticatedUsersOnly: true,
|
||||
}),
|
||||
portal(),
|
||||
],
|
||||
}),
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
expo(),
|
||||
{{/if}}
|
||||
],
|
||||
{{else}}
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
plugins: [expo()],
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
});
|
||||
{{/if}}
|
||||
|
||||
@@ -80,6 +140,10 @@ import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
import { expo } from "@better-auth/expo";
|
||||
{{/if}}
|
||||
{{#if (eq payments "polar")}}
|
||||
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
||||
import { polarClient } from "./payments";
|
||||
{{/if}}
|
||||
import { db } from "../db";
|
||||
import * as schema from "../db/schema/auth";
|
||||
import { env } from "cloudflare:workers";
|
||||
@@ -109,9 +173,32 @@ export const auth = betterAuth<BetterAuthOptions>({
|
||||
httpOnly: true,
|
||||
},
|
||||
},
|
||||
{{#if (eq payments "polar")}}
|
||||
plugins: [
|
||||
polar({
|
||||
client: polarClient,
|
||||
createCustomerOnSignUp: true,
|
||||
enableCustomerPortal: true,
|
||||
use: [
|
||||
checkout({
|
||||
products: [
|
||||
{
|
||||
productId: "your-product-id",
|
||||
slug: "pro",
|
||||
},
|
||||
],
|
||||
successUrl: env.POLAR_SUCCESS_URL,
|
||||
authenticatedUsersOnly: true,
|
||||
}),
|
||||
portal(),
|
||||
],
|
||||
}),
|
||||
],
|
||||
{{else}}
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
plugins: [expo()],
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
});
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
@@ -122,6 +209,10 @@ import { mongodbAdapter } from "better-auth/adapters/mongodb";
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
import { expo } from "@better-auth/expo";
|
||||
{{/if}}
|
||||
{{#if (eq payments "polar")}}
|
||||
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
||||
import { polarClient } from "./payments";
|
||||
{{/if}}
|
||||
import { client } from "../db";
|
||||
|
||||
export const auth = betterAuth<BetterAuthOptions>({
|
||||
@@ -141,9 +232,35 @@ export const auth = betterAuth<BetterAuthOptions>({
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
{{#if (eq payments "polar")}}
|
||||
plugins: [
|
||||
polar({
|
||||
client: polarClient,
|
||||
createCustomerOnSignUp: true,
|
||||
enableCustomerPortal: true,
|
||||
use: [
|
||||
checkout({
|
||||
products: [
|
||||
{
|
||||
productId: "your-product-id",
|
||||
slug: "pro",
|
||||
},
|
||||
],
|
||||
successUrl: process.env.POLAR_SUCCESS_URL,
|
||||
authenticatedUsersOnly: true,
|
||||
}),
|
||||
portal(),
|
||||
],
|
||||
}),
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
expo(),
|
||||
{{/if}}
|
||||
],
|
||||
{{else}}
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
, plugins: [expo()]
|
||||
plugins: [expo()],
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
});
|
||||
{{/if}}
|
||||
@@ -153,6 +270,10 @@ import { betterAuth, type BetterAuthOptions } from "better-auth";
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
import { expo } from "@better-auth/expo";
|
||||
{{/if}}
|
||||
{{#if (eq payments "polar")}}
|
||||
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
||||
import { polarClient } from "./payments";
|
||||
{{/if}}
|
||||
|
||||
export const auth = betterAuth<BetterAuthOptions>({
|
||||
database: "", // Invalid configuration
|
||||
@@ -171,9 +292,35 @@ export const auth = betterAuth<BetterAuthOptions>({
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
{{#if (eq payments "polar")}}
|
||||
plugins: [
|
||||
polar({
|
||||
client: polarClient,
|
||||
createCustomerOnSignUp: true,
|
||||
enableCustomerPortal: true,
|
||||
use: [
|
||||
checkout({
|
||||
products: [
|
||||
{
|
||||
productId: "your-product-id",
|
||||
slug: "pro",
|
||||
},
|
||||
],
|
||||
successUrl: process.env.POLAR_SUCCESS_URL,
|
||||
authenticatedUsersOnly: true,
|
||||
}),
|
||||
portal(),
|
||||
],
|
||||
}),
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
expo(),
|
||||
{{/if}}
|
||||
],
|
||||
{{else}}
|
||||
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
||||
, plugins: [expo()]
|
||||
plugins: [expo()],
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
});
|
||||
{{/if}}
|
||||
|
||||
Reference in New Issue
Block a user