Mercurial > gemma
comparison pkg/controllers/importconfig.go @ 3552:ffc8fb059d1a
refactor password persistence for import configurations.
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Fri, 31 May 2019 14:29:21 +0200 |
parents | 30f6647b8856 |
children | efa468653d48 |
comparison
equal
deleted
inserted
replaced
3551:a5448426e4e2 | 3552:ffc8fb059d1a |
---|---|
96 } | 96 } |
97 | 97 |
98 _, oldCron := pc.Attributes.Get("cron") | 98 _, oldCron := pc.Attributes.Get("cron") |
99 | 99 |
100 session, _ := auth.GetSession(req) | 100 session, _ := auth.GetSession(req) |
101 // When a password is stored it doesn't get retransmitted to the client | |
102 // in order to prevent password leakage | |
103 // When the user changes the import configuration without a new password | |
104 // the old password should be conserved | |
101 oldPasswd := pc.Attributes["password"] | 105 oldPasswd := pc.Attributes["password"] |
102 pc.User = session.User | 106 pc.User = session.User |
103 pc.Attributes = common.Attributes{} | 107 pc.Attributes = common.Attributes{} |
104 pc.Attributes.Marshal(config) | 108 pc.Attributes["password"] = oldPasswd |
105 if oldPasswd != "" && pc.Attributes["password"] == "" { | 109 pc.Attributes.Marshal(config) // Marshal only overwrites keys present in config |
106 pc.Attributes["password"] = oldPasswd | |
107 } | |
108 cron, newCron := pc.Attributes.Get("cron") | 110 cron, newCron := pc.Attributes.Get("cron") |
109 | 111 |
110 var tx *sql.Tx | 112 var tx *sql.Tx |
111 if tx, err = conn.BeginTx(ctx, nil); err != nil { | 113 if tx, err = conn.BeginTx(ctx, nil); err != nil { |
112 return | 114 return |