Improve admin credentials error messages with setup instructions

This commit is contained in:
2025-10-11 21:22:38 +02:00
parent 62605b3689
commit a904a0d1a3
2 changed files with 21 additions and 3 deletions

View File

@@ -48,7 +48,13 @@ func DefaultConfig() *Config {
// validate checks if the configuration is valid
func (c *Config) validate() error {
if c.AdminEmail == "" || c.AdminPassword == "" {
return fmt.Errorf("LEMMA_ADMIN_EMAIL and LEMMA_ADMIN_PASSWORD must be set")
return fmt.Errorf(`admin credentials not configured
To get started, set these environment variables:
export LEMMA_ADMIN_EMAIL="admin@example.com"
export LEMMA_ADMIN_PASSWORD="your-secure-password"
Then start the server again.`)
}
// Validate encryption key if provided (if not provided, it will be auto-generated)

View File

@@ -168,7 +168,13 @@ func TestLoad(t *testing.T) {
setEnv(t, "LEMMA_ADMIN_PASSWORD", "password123")
setEnv(t, "LEMMA_ENCRYPTION_KEY", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=")
},
expectedError: "LEMMA_ADMIN_EMAIL and LEMMA_ADMIN_PASSWORD must be set",
expectedError: `admin credentials not configured
To get started, set these environment variables:
export LEMMA_ADMIN_EMAIL="admin@example.com"
export LEMMA_ADMIN_PASSWORD="your-secure-password"
Then start the server again.`,
},
{
name: "missing admin password",
@@ -177,7 +183,13 @@ func TestLoad(t *testing.T) {
setEnv(t, "LEMMA_ADMIN_EMAIL", "admin@example.com")
setEnv(t, "LEMMA_ENCRYPTION_KEY", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=")
},
expectedError: "LEMMA_ADMIN_EMAIL and LEMMA_ADMIN_PASSWORD must be set",
expectedError: `admin credentials not configured
To get started, set these environment variables:
export LEMMA_ADMIN_EMAIL="admin@example.com"
export LEMMA_ADMIN_PASSWORD="your-secure-password"
Then start the server again.`,
},
{
name: "invalid encryption key",