Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/supabase/initialize-admin-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ 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.INITIAL_ADMIN_PASSWORD;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the setup contract: without INITIAL_ADMIN_PASSWORD, first startup now skips admin user creation entirely.

That behavior is not reflected in the setup docs on this PR head. .env.example still only lists ADMIN_EMAIL, and the README still says the admin account is automatically created with password 123456.

Concrete fix: add INITIAL_ADMIN_PASSWORD to .env.example, include it in the README environment block/table, and update the User Accounts section to say the admin user is created only when INITIAL_ADMIN_PASSWORD is set. Otherwise a new developer can follow the README exactly and end up with no admin account.

if (!adminPassword) {
console.warn("INITIAL_ADMIN_PASSWORD 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.
const { data: adminUserExists, error: rpcError } = await adminAuthClient.rpc(
Expand Down Expand Up @@ -112,4 +115,4 @@ const createAdminUserIfNotExists = async () => {

// This is the key: we call the function immediately.
// When this file is imported, this function will run.
createAdminUserIfNotExists();
createAdminUserIfNotExists();