mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 15:44:21 +00:00
Improve admin credentials error messages with setup instructions
This commit is contained in:
@@ -48,7 +48,13 @@ func DefaultConfig() *Config {
|
|||||||
// validate checks if the configuration is valid
|
// validate checks if the configuration is valid
|
||||||
func (c *Config) validate() error {
|
func (c *Config) validate() error {
|
||||||
if c.AdminEmail == "" || c.AdminPassword == "" {
|
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)
|
// Validate encryption key if provided (if not provided, it will be auto-generated)
|
||||||
|
|||||||
@@ -168,7 +168,13 @@ func TestLoad(t *testing.T) {
|
|||||||
setEnv(t, "LEMMA_ADMIN_PASSWORD", "password123")
|
setEnv(t, "LEMMA_ADMIN_PASSWORD", "password123")
|
||||||
setEnv(t, "LEMMA_ENCRYPTION_KEY", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=")
|
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",
|
name: "missing admin password",
|
||||||
@@ -177,7 +183,13 @@ func TestLoad(t *testing.T) {
|
|||||||
setEnv(t, "LEMMA_ADMIN_EMAIL", "admin@example.com")
|
setEnv(t, "LEMMA_ADMIN_EMAIL", "admin@example.com")
|
||||||
setEnv(t, "LEMMA_ENCRYPTION_KEY", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY=")
|
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",
|
name: "invalid encryption key",
|
||||||
|
|||||||
Reference in New Issue
Block a user