config: Avoid stale credentials in memory. (#4466)

This commit is contained in:
Harshavardhana
2017-08-08 12:14:32 -07:00
committed by GitHub
parent 6f7ace3d3e
commit f346ca44f0
4 changed files with 26 additions and 7 deletions
+5 -2
View File
@@ -69,11 +69,14 @@ func (br *browserPeerAPIHandlers) SetAuthPeer(args SetAuthPeerArgs, reply *AuthR
}
// Update credentials in memory
serverConfig.SetCredential(args.Creds)
prevCred := serverConfig.SetCredential(args.Creds)
// Save credentials to config file
if err := serverConfig.Save(); err != nil {
errorIf(err, "Error updating config file with new credentials sent from browser RPC.")
// Save the current creds when failed to update.
serverConfig.SetCredential(prevCred)
errorIf(err, "Unable to update the config with new credentials sent from browser RPC.")
return err
}