fix: credential data corruption - Create handler mutating store pointer

- CreateCredential was setting cred.Data = cred.Masked directly on the
  store pointer, corrupting stored credentials with masked data
- Fixed by using a value copy for API response
- Also fix nextID starts at 1 to avoid ID=0 issue
This commit is contained in:
2026-07-24 19:16:35 +08:00
parent 471fe76384
commit 6498903a7c
2 changed files with 7 additions and 5 deletions
+4 -3
View File
@@ -89,9 +89,10 @@ func (h *CredentialHandler) CreateCredential(c *gin.Context) {
return
}
// Return without secrets
cred.Data = cred.Masked
c.JSON(http.StatusCreated, cred)
// Return without secrets (use a copy to avoid mutating store)
resp := *cred
resp.Data = cred.Masked
c.JSON(http.StatusCreated, &resp)
}
// UpdateCredential updates a credential