Merge pull request #1981 from ywk253100/170408_target

Fix bug in updating target
This commit is contained in:
Daniel Jiang 2017-04-11 11:04:31 +08:00 committed by GitHub
commit e6380567d4

View File

@ -245,6 +245,13 @@ func (t *TargetAPI) Put() {
if hasEnabledPolicy {
t.CustomAbort(http.StatusBadRequest, "the target is associated with policy which is enabled")
}
if len(target.Password) != 0 {
target.Password, err = utils.ReversibleDecrypt(target.Password, t.secretKey)
if err != nil {
log.Errorf("failed to decrypt password: %v", err)
t.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
}
req := struct {
Name *string `json:"name"`