all: Refactor preparing configuration (#7127)

This commit is contained in:
Simon Frei
2020-11-20 14:21:54 +01:00
committed by GitHub
parent 641b7aee38
commit 24af89c8e2
19 changed files with 207 additions and 147 deletions
+8
View File
@@ -11,6 +11,8 @@ import (
"os"
"strconv"
"strings"
"github.com/syncthing/syncthing/lib/rand"
)
func (c GUIConfiguration) IsAuthEnabled() bool {
@@ -126,6 +128,12 @@ func (c GUIConfiguration) IsValidAPIKey(apiKey string) bool {
}
}
func (c *GUIConfiguration) prepare() {
if c.APIKey == "" {
c.APIKey = rand.String(32)
}
}
func (c GUIConfiguration) Copy() GUIConfiguration {
return c
}