diff options
author | Jakob Borg <jakob@nym.se> | 2014-05-24 21:00:47 +0200 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-05-24 21:00:47 +0200 |
commit | 217f29de76bf0a0fded68afe9b2f956ac6c00ca5 (patch) | |
tree | 93fa2da2f0875fccddceb3caaf00b334b96ef6a5 /cmd | |
parent | 8661afcb4f0cbbaf48d8236a49255182599ac2ca (diff) |
Don't mess up unset properties of new nodes/repos
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/syncthing/gui.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index 1a9ca01251..0fa8944496 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -184,23 +184,24 @@ func restGetConfig(w http.ResponseWriter) { } func restPostConfig(req *http.Request) { - var prevPassHash = cfg.GUI.Password - err := json.NewDecoder(req.Body).Decode(&cfg) + var newCfg config.Configuration + err := json.NewDecoder(req.Body).Decode(&newCfg) if err != nil { l.Warnln(err) } else { - if cfg.GUI.Password == "" { + if newCfg.GUI.Password == "" { // Leave it empty - } else if cfg.GUI.Password != unchangedPassword { - hash, err := bcrypt.GenerateFromPassword([]byte(cfg.GUI.Password), 0) + } else if newCfg.GUI.Password == unchangedPassword { + newCfg.GUI.Password = cfg.GUI.Password + } else { + hash, err := bcrypt.GenerateFromPassword([]byte(newCfg.GUI.Password), 0) if err != nil { l.Warnln(err) } else { - cfg.GUI.Password = string(hash) + newCfg.GUI.Password = string(hash) } - } else { - cfg.GUI.Password = prevPassHash } + cfg = newCfg saveConfig() configInSync = false } |