Let absence of password be absence

This commit is contained in:
Jakob Borg 2014-04-19 22:36:12 +02:00
parent c64549471a
commit 9349eb77cd

View File

@ -109,7 +109,9 @@ func restGetConnections(m *Model, w http.ResponseWriter) {
func restGetConfig(w http.ResponseWriter) { func restGetConfig(w http.ResponseWriter) {
encCfg := cfg encCfg := cfg
encCfg.GUI.Password = unchangedPassword if encCfg.GUI.Password != "" {
encCfg.GUI.Password = unchangedPassword
}
json.NewEncoder(w).Encode(encCfg) json.NewEncoder(w).Encode(encCfg)
} }
@ -119,7 +121,9 @@ func restPostConfig(req *http.Request) {
if err != nil { if err != nil {
warnln(err) warnln(err)
} else { } else {
if cfg.GUI.Password != unchangedPassword { if cfg.GUI.Password == "" {
// Leave it empty
} else if cfg.GUI.Password != unchangedPassword {
hash, err := bcrypt.GenerateFromPassword([]byte(cfg.GUI.Password), 0) hash, err := bcrypt.GenerateFromPassword([]byte(cfg.GUI.Password), 0)
if err != nil { if err != nil {
warnln(err) warnln(err)