Administrator Setup and Recovery
Accounts must be created after the schema is ready. There is no default administrator password. ADMIN_USERNAMES only reserves registration names.
First Setup with Actions
Set both EDGECHAT_ADMIN_USERNAME and EDGECHAT_ADMIN_PASSWORD as Repository Secrets, then rerun 00 Deploy Worker. If omitted initially, add them and reuse the existing database.
EDGECHAT_ADMIN_DISPLAY_NAME is optional. Legacy CFCHAT_ADMIN_* names remain supported, with new names taking precedence. Later updates can omit initial credentials if an active super administrator exists.
Initialization creates missing accounts only. Change an existing password within the site; editing a GitHub Secret does not reset it.
Manual Initialization
Complete D1 migrations and verification first. Use Node.js 24 and run npm ci in the project root. Confirm that DB in wrangler.toml points to the site's database, and set your own CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID in the terminal environment.
PowerShell
$env:EDGECHAT_ADMIN_USERNAME = 'admin'
$env:EDGECHAT_ADMIN_PASSWORD = [System.Net.NetworkCredential]::new('', (Read-Host 'Set administrator password' -AsSecureString)).Password
npm run admin:bootstrap
$bootstrapExit = $LASTEXITCODE
Remove-Item Env:EDGECHAT_ADMIN_PASSWORD
if ($bootstrapExit -ne 0) { throw 'Administrator SQL generation failed' }
npx wrangler d1 execute DB --remote --config wrangler.toml --file .tmp/edgechat-admin-upsert.sqlBash / macOS / Linux
export EDGECHAT_ADMIN_USERNAME=admin
read -r -s -p 'Set administrator password: ' EDGECHAT_ADMIN_PASSWORD
export EDGECHAT_ADMIN_PASSWORD
if npm run admin:bootstrap; then
unset EDGECHAT_ADMIN_PASSWORD
npx wrangler d1 execute DB --remote --config wrangler.toml --file .tmp/edgechat-admin-upsert.sql
else
unset EDGECHAT_ADMIN_PASSWORD
fiGenerated SQL contains only password hashes and salts. After applying it, sign in immediately if the site is already deployed. For local development, replace --remote with --local. Remove temporary SQL after use.
Recover an Existing Super Administrator
Use this for forgotten passwords, an existing username, or a site without an active super administrator. Back up D1, then follow the repository's explicit recovery procedure:
- Identify the local user ID to recover.
- Set
EDGECHAT_RECOVER_USER_IDandEDGECHAT_RECOVER_PASSWORDin the terminal environment. - Run
node .github/scripts/generate-admin-recovery-sql.mjs --confirm-super-admin-recovery. - Review the generated SQL and database target before applying it as described in the recovery guide.
Recovery resets the password, invalidates old sessions, and records an audit event. It is a one-time manual operation.