From 2a718ef6d81754db0f84e29e1f7769b263b5cbb6 Mon Sep 17 00:00:00 2001 From: IRHM <37304121+IRHM@users.noreply.github.com> Date: Thu, 7 Mar 2024 11:23:56 +0000 Subject: [PATCH] #400 Fix signup_enabled default config value Set defaults when generating config so they are stored in the json file. --- server/config.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/config.go b/server/config.go index f7b1a001..3170028e 100644 --- a/server/config.go +++ b/server/config.go @@ -64,11 +64,8 @@ func (c *ServerConfig) GetSafe() ServerConfig { } var ( - // Our server config.. set defaults here, then `readConfig` - // will overwrite if provided in watcharr.json cfg file. - Config = ServerConfig{ - SIGNUP_ENABLED: true, - } + // Our server config.. `readConfig` will overwrite from watcharr.json cfg file. + Config = ServerConfig{} ) // Read config file @@ -102,19 +99,22 @@ func initFromConfig() error { } // Generate new barebones watcharr.json config file. -// Currently only JWT_SECRET is required, so this method -// generates a secret. +// Generates a JWT_SECRET and set default config. func generateConfig() error { key, err := generateString(64) if err != nil { return err } - cfg := ServerConfig{JWT_SECRET: key} + cfg := ServerConfig{ + JWT_SECRET: key, + // Other defaults.. + SIGNUP_ENABLED: true, + } barej, err := json.MarshalIndent(cfg, "", "\t") if err != nil { return err } - Config.JWT_SECRET = cfg.JWT_SECRET + Config = cfg return os.WriteFile("./data/watcharr.json", barej, 0755) }