include count in listsecrets
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-23 12:33:08 +11:00
parent 19ffc9e683
commit 8ff92e206e

View File

@@ -161,7 +161,7 @@ func retrieveSpecifiedSecret(s *models.Secret, c *gin.Context) {
func ListSecrets(c *gin.Context) {
var UserId int
var output []ListSecret
var results []ListSecret
//var results []models.Secret
s := models.Secret{}
@@ -184,18 +184,18 @@ func ListSecrets(c *gin.Context) {
// Extract the normal secret fields from the allowed list
for _, secret := range secretList {
output = append(output, ListSecret(secret.Secret))
results = append(results, ListSecret(secret.Secret))
}
// Create audit record
a := models.Audit{
UserId: UserId,
IpAddress: c.ClientIP(),
EventText: fmt.Sprintf("Listed %d secrets accessible to user", len(output)),
EventText: fmt.Sprintf("Listed %d secrets accessible to user", len(results)),
}
a.AuditLogAdd()
// output results as json
c.JSON(http.StatusOK, gin.H{"message": "success", "data": output})
c.JSON(http.StatusOK, gin.H{"message": "success", "data": results, "count": len(results)})
}