test storesecret update
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -162,7 +162,7 @@ func retrieveSpecifiedSecret(s *models.Secret, c *gin.Context) {
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
var UserId int
|
||||
var results []models.Secret
|
||||
/*
|
||||
user_id, err := token.ExtractTokenID(c)
|
||||
@@ -171,10 +171,16 @@ func retrieveSpecifiedSecret(s *models.Secret, c *gin.Context) {
|
||||
return
|
||||
}
|
||||
*/
|
||||
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"})
|
||||
@@ -189,7 +195,7 @@ func retrieveSpecifiedSecret(s *models.Secret, c *gin.Context) {
|
||||
return
|
||||
} else if len(safeList) == 1 {
|
||||
s.SafeId = safeList[0].SafeId
|
||||
results, err = models.SecretsGetMultipleSafes(s, []int{s.SafeId})
|
||||
results, err = models.SecretsGetFromMultipleSafes(s, []int{s.SafeId})
|
||||
} else {
|
||||
// Create a list of all the safes this user can access
|
||||
var safeIds []int
|
||||
@@ -197,7 +203,7 @@ func retrieveSpecifiedSecret(s *models.Secret, c *gin.Context) {
|
||||
safeIds = append(safeIds, safe.SafeId)
|
||||
}
|
||||
|
||||
results, err = models.SecretsGetMultipleSafes(s, safeIds)
|
||||
results, err = models.SecretsGetFromMultipleSafes(s, safeIds)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user