improve README
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-09 15:28:38 +11:00
parent 43fa0b02aa
commit 00f87ccb71
3 changed files with 41 additions and 35 deletions

View File

@@ -216,38 +216,24 @@ func retrieveSpecifiedSecret(s *models.Secret, c *gin.Context) {
return
}
}
func ListSecrets(c *gin.Context) {
var UserId int
var output []ListSecret
// TODO implement with new schema
/*
var results []models.Secret
// Get the user and role id of the requestor
u, err := models.UserGetRoleFromToken(c)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// If user is admin then list everything, otherwise only list for current role
results, err = models.GetSecrets(&models.Secret{RoleId: u.RoleId}, u.Admin)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
for _, v := range results {
output = append(output, ListSecret(v))
}
*/
var results []models.Secret
s := models.Secret{}
user_id := c.GetInt("user-id")
// Get userId that we stored in the context earlier
if val, ok := c.Get("user-id"); !ok {
c.JSON(http.StatusBadRequest, gin.H{"error": "error determining user"})
return
} else {
UserId = val.(int)
}
// Work out which safe to query for this user if the safe was not specified
safeList, err := models.UserGetSafesAllowed(int(user_id))
safeList, err := models.UserGetSafesAllowed(int(UserId))
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "error determining user safes"})