diff --git a/.env.example b/.env.example index a73c123..0d33651 100644 --- a/.env.example +++ b/.env.example @@ -11,3 +11,4 @@ CIRCLE_USDC_TOKEN_ID=15dc2b5d-0994-58b0-bf8c-3a0501148ee8 # Misc ADMIN_EMAIL=admin@admin.com +ADMIN_PASSWORD=your-secure-admin-password diff --git a/README.md b/README.md index 50ca285..3b11235 100644 --- a/README.md +++ b/README.md @@ -131,10 +131,12 @@ ADMIN_EMAIL=admin@admin.com ### Admin Account -On first startup, an admin user is automatically created with the following credentials: +On first startup, an admin user is automatically created using the credentials +defined in your `.env.local` file: -- **Email:** `admin@admin.com` -- **Password:** `123456` +- **Email:** The value of `ADMIN_EMAIL` (defaults to `admin@admin.com`) +- **Password:** The value of `ADMIN_PASSWORD` (**required** — the app will not + create the admin account if this is not set) The admin account has access to the **Admin Dashboard**, which provides an overview of all users, wallets, and transactions in the system. diff --git a/lib/supabase/initialize-admin-user.ts b/lib/supabase/initialize-admin-user.ts index 95c59c6..9d7870a 100644 --- a/lib/supabase/initialize-admin-user.ts +++ b/lib/supabase/initialize-admin-user.ts @@ -45,8 +45,15 @@ const createAdminUserIfNotExists = async () => { return; } - const adminEmail = "admin@admin.com"; - const adminPassword = "123456"; + const adminEmail = process.env.ADMIN_EMAIL ?? "admin@admin.com"; + const adminPassword = process.env.ADMIN_PASSWORD; + + if (!adminPassword) { + console.error( + "❌ ADMIN_PASSWORD environment variable is not set. Skipping admin user creation." + ); + return; + } // We call our custom database function via RPC (Remote Procedure Call). // This is a single, fast, and scalable database query. @@ -112,4 +119,4 @@ const createAdminUserIfNotExists = async () => { // This is the key: we call the function immediately. // When this file is imported, this function will run. -createAdminUserIfNotExists(); \ No newline at end of file +createAdminUserIfNotExists();