Skip to content

Commit

Permalink
Copy authConfigs on save so data is not modified
Browse files Browse the repository at this point in the history
SaveConfig sets the Username and Password to an empty string
on save.  A copy of the authConfigs need to be made so that the
in memory data is not modified.
  • Loading branch information
crosbymichael committed Jul 25, 2013
1 parent 6ae3305 commit 9332c00
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,19 @@ func SaveConfig(configFile *ConfigFile) error {
os.Remove(confFile)
return nil
}

configs := make(map[string]AuthConfig, len(configFile.Configs))
for k, authConfig := range configFile.Configs {
authConfig.Auth = encodeAuth(&authConfig)
authConfig.Username = ""
authConfig.Password = ""
configFile.Configs[k] = authConfig
authCopy := authConfig

authCopy.Auth = encodeAuth(&authCopy)
authCopy.Username = ""
authCopy.Password = ""

configs[k] = authCopy
}

b, err := json.Marshal(configFile.Configs)
b, err := json.Marshal(configs)
if err != nil {
return err
}
Expand Down

0 comments on commit 9332c00

Please sign in to comment.