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:
@@ -31,8 +31,8 @@ type SecretInput struct {
|
||||
SecretValue string `json:"secretValue"`
|
||||
}
|
||||
|
||||
func FindSafeId(UserId int, input SecretInput) (int, error) {
|
||||
|
||||
// CheckSafeAllowed returns the SafeId of an allowed safe containing the secret specified by SafeId or SafeName
|
||||
func CheckSafeAllowed(UserId int, input SecretInput) (int, error) {
|
||||
// Check which safes a user is allowed to access
|
||||
allowedSafes, err := models.UserGetSafesAllowed(UserId)
|
||||
if err != nil {
|
||||
@@ -122,7 +122,9 @@ func StoreSecret(c *gin.Context) {
|
||||
//log.Printf("user_id: %v\n", user_id)
|
||||
}
|
||||
|
||||
safeId, err := FindSafeId(UserId, input)
|
||||
// TODO replace FindSafeId with models.SecretsGetAllowed()
|
||||
|
||||
safeId, err := CheckSafeAllowed(UserId, input)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
@@ -130,7 +132,11 @@ func StoreSecret(c *gin.Context) {
|
||||
s.SafeId = safeId
|
||||
|
||||
// If this secret already exists in the database then generate an error
|
||||
checkExists, err := models.GetSecrets(&s, false)
|
||||
//checkExists, err := models.GetSecrets(&s, false)
|
||||
checkExists, err := models.SecretsGetFromMultipleSafes(&s, []int{safeId})
|
||||
|
||||
// TODO replace GetSecrets with SecretsGetFromMultipleSafes
|
||||
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
|
Reference in New Issue
Block a user