mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 11:28:59 +00:00
Don't mess up unset properties of new nodes/repos
This commit is contained in:
parent
8661afcb4f
commit
217f29de76
@ -184,23 +184,24 @@ func restGetConfig(w http.ResponseWriter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func restPostConfig(req *http.Request) {
|
func restPostConfig(req *http.Request) {
|
||||||
var prevPassHash = cfg.GUI.Password
|
var newCfg config.Configuration
|
||||||
err := json.NewDecoder(req.Body).Decode(&cfg)
|
err := json.NewDecoder(req.Body).Decode(&newCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Warnln(err)
|
l.Warnln(err)
|
||||||
} else {
|
} else {
|
||||||
if cfg.GUI.Password == "" {
|
if newCfg.GUI.Password == "" {
|
||||||
// Leave it empty
|
// Leave it empty
|
||||||
} else if cfg.GUI.Password != unchangedPassword {
|
} else if newCfg.GUI.Password == unchangedPassword {
|
||||||
hash, err := bcrypt.GenerateFromPassword([]byte(cfg.GUI.Password), 0)
|
newCfg.GUI.Password = cfg.GUI.Password
|
||||||
|
} else {
|
||||||
|
hash, err := bcrypt.GenerateFromPassword([]byte(newCfg.GUI.Password), 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Warnln(err)
|
l.Warnln(err)
|
||||||
} else {
|
} else {
|
||||||
cfg.GUI.Password = string(hash)
|
newCfg.GUI.Password = string(hash)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
cfg.GUI.Password = prevPassHash
|
|
||||||
}
|
}
|
||||||
|
cfg = newCfg
|
||||||
saveConfig()
|
saveConfig()
|
||||||
configInSync = false
|
configInSync = false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user