This commit is contained in:
2023-04-03 11:12:50 +10:00
parent c229e93103
commit 13b0f87e7d
2 changed files with 26 additions and 0 deletions

View File

@@ -102,6 +102,7 @@ func UpdateSecret(c *gin.Context) {
// Populate fields
s := models.Secret{}
s.UserName = input.UserName
s.DeviceName = input.DeviceName
s.DeviceCategory = input.DeviceCategory
@@ -128,6 +129,17 @@ func UpdateSecret(c *gin.Context) {
// Set the secret id with the one retrieved from the database
s.SecretId = checkExists[0].SecretId
// check for empty fields in the update request and update from the existing record
if s.UserName == "" {
s.UserName = checkExists[0].UserName
}
if s.DeviceCategory == "" {
s.DeviceCategory = checkExists[0].DeviceCategory
}
if s.DeviceName == "" {
s.DeviceName = checkExists[0].DeviceName
}
// Encrypt secret
s.Secret = input.SecretValue
_, err = s.EncryptSecret()