🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Refactor authentication and environment configuration
Bill Yang1d0ffdf9d999
diff --git a/.env.example b/.env.exampledeleted file mode 100644index 94da3bc48..000000000--- a/.env.example+++ /dev/null@@ -1,2 +0,0 @@-BASE_URL=[your-base-url]-BETTER_AUTH_SECRET=[your-better-auth-secret]\ No newline at end of filediff --git a/docker-compose.cloud.yml b/docker-compose.cloud.ymlindex e5e5a31c9..013e7798c 100644--- a/docker-compose.cloud.yml+++ b/docker-compose.cloud.yml@@ -68,6 +68,7 @@ services:- POSTGRES_PASSWORD=frog- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}- BASE_URL=${BASE_URL}+ - DISABLE_SIGNUP=${DISABLE_SIGNUP}# below is only for rybbit cloud- CLOUD=${CLOUD}- STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}diff --git a/docker-compose.dev.yml b/docker-compose.dev.ymlindex df3c73c13..a7093b807 100644--- a/docker-compose.dev.yml+++ b/docker-compose.dev.yml@@ -70,8 +70,7 @@ services:- POSTGRES_PASSWORD=frog- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}- BASE_URL=${BASE_URL}- - STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}- - STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET}+ - DISABLE_SIGNUP=${DISABLE_SIGNUP}# below is only for rybbit cloud- CLOUD=${CLOUD}- STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}diff --git a/docker-compose.yml b/docker-compose.ymlindex 4b82c00fc..72d72fc8d 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -68,6 +68,7 @@ services:- POSTGRES_PASSWORD=frog- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}- BASE_URL=${BASE_URL}+ - DISABLE_SIGNUP=${DISABLE_SIGNUP}depends_on:clickhouse:condition: service_healthydiff --git a/server/src/lib/auth.ts b/server/src/lib/auth.tsindex cf634c67e..8ebf81f0e 100644--- a/server/src/lib/auth.ts+++ b/server/src/lib/auth.ts@@ -6,7 +6,7 @@ import { eq } from "drizzle-orm";import pg from "pg";import { db } from "../db/postgres/postgres.js";import * as schema from "../db/postgres/schema.js";-import { IS_CLOUD } from "./const.js";+import { DISABLE_SIGNUP } from "./const.js";dotenv.config();@@ -33,6 +33,7 @@ export let auth: AuthType | null = betterAuth({}),emailAndPassword: {enabled: true,+ disableSignUp: DISABLE_SIGNUP,},socialProviders: {google: {@@ -87,8 +88,8 @@ export function initAuth(allowedOrigins: string[]) {enabled: true,// Disable email verification for nowrequireEmailVerification: false,+ disableSignUp: DISABLE_SIGNUP,},-socialProviders: {google: {clientId: process.env.GOOGLE_CLIENT_ID!,diff --git a/server/src/lib/const.ts b/server/src/lib/const.tsindex fb963bb8e..d3fb3aeb9 100644--- a/server/src/lib/const.ts+++ b/server/src/lib/const.ts@@ -3,6 +3,7 @@ import dotenv from "dotenv";dotenv.config();export const IS_CLOUD = process.env.CLOUD === "true";+export const DISABLE_SIGNUP = process.env.DISABLE_SIGNUP === "true";// Trial constantsexport const TRIAL_DURATION_DAYS = 14;diff --git a/setup.sh b/setup.shindex 7ac2e3315..3a5281a8a 100644--- a/setup.sh+++ b/setup.sh@@ -31,6 +31,7 @@ cat > .env << EOLDOMAIN_NAME=${DOMAIN_NAME}BASE_URL=${BASE_URL}BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}+DISABLE_SIGNUP=falseEOLecho ".env file created successfully with domain ${DOMAIN_NAME}."