add event log retrieval
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-17 12:20:01 +11:00
parent 5f63ee235b
commit f68bd9637d
8 changed files with 75 additions and 12 deletions

View File

@@ -82,7 +82,7 @@ func DeleteUser(c *gin.Context) {
UserId: RequestingUserId,
EventText: fmt.Sprintf("Deleted User Id %d", testUser.UserId),
}
a.AuditAdd()
a.AutidLogAdd()
c.JSON(http.StatusOK, gin.H{"message": "user deletion success"})
}
@@ -183,7 +183,7 @@ func AddUser(c *gin.Context) {
UserId: RequestingUserId,
EventText: fmt.Sprintf("Created User Id %d", u.UserId),
}
a.AuditAdd()
a.AutidLogAdd()
c.JSON(http.StatusOK, gin.H{"message": "user registration success", "data": u})
}

View File

@@ -0,0 +1,23 @@
package controllers
import (
"fmt"
"log"
"net/http"
"smt/models"
"github.com/gin-gonic/gin"
)
func GetAuditLogsHandler(c *gin.Context) {
logs, err := models.AuditLogList()
if err != nil {
errString := fmt.Sprintf("error retrieving audit logs : '%s'", err)
log.Printf("GetAuditLogsHandler %s\n", errString)
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
return
}
c.JSON(http.StatusOK, gin.H{"message": "success", "data": logs})
}

View File

@@ -164,7 +164,7 @@ func retrieveSpecifiedSecret(s *models.Secret, c *gin.Context) {
UserId: UserId,
EventText: fmt.Sprintf("Retrieved Secret Id %d", results[0].SecretId),
}
a.AuditAdd()
a.AutidLogAdd()
// output results as json
c.JSON(http.StatusOK, gin.H{"message": "success", "data": results})
@@ -210,7 +210,7 @@ func ListSecrets(c *gin.Context) {
UserId: UserId,
EventText: fmt.Sprintf("Listed %d secrets, %+v", len(output), s),
}
a.AuditAdd()
a.AutidLogAdd()
// output results as json
c.JSON(http.StatusOK, gin.H{"message": "success", "data": output})

View File

@@ -149,7 +149,7 @@ func StoreSecret(c *gin.Context) {
UserId: UserId,
EventText: fmt.Sprintf("Created Secret Id %d", s.SecretId),
}
a.AuditAdd()
a.AutidLogAdd()
c.JSON(http.StatusOK, gin.H{"message": "secret stored successfully", "data": models.SecretRestricted(s)})
}
@@ -370,7 +370,7 @@ func UpdateSecret(c *gin.Context) {
UserId: UserId,
EventText: fmt.Sprintf("Updated Secret Id %d", s.SecretId),
}
a.AuditAdd()
a.AutidLogAdd()
c.JSON(http.StatusOK, gin.H{"message": "secret updated successfully", "data": models.SecretRestricted(s)})
} else {
@@ -460,7 +460,7 @@ func DeleteSecret(c *gin.Context) {
UserId: UserId,
EventText: fmt.Sprintf("Deleted Secret Id %d", s.SecretId),
}
a.AuditAdd()
a.AutidLogAdd()
c.JSON(http.StatusOK, gin.H{"message": "secret deleted successfully"})
} else {