From 1f80d0b9ada0a0cf33b7e0fe79993db10b8f7a60 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 4 Apr 2023 13:59:28 +1000 Subject: [PATCH] default storesecret roleid to roleid of requesting user --- controllers/store_secrets.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/controllers/store_secrets.go b/controllers/store_secrets.go index 329a0c3..552b5a4 100644 --- a/controllers/store_secrets.go +++ b/controllers/store_secrets.go @@ -36,12 +36,13 @@ func StoreSecret(c *gin.Context) { s.DeviceName = input.DeviceName s.DeviceCategory = input.DeviceCategory - // Default role ID is 1 if not defined + // If RoleID is not defined then default to the same role as the user requesting secret to be stored if input.RoleId != 0 { s.RoleId = input.RoleId } else { - log.Printf("StoreSecret setting default RoleId of 1\n") - s.RoleId = 1 + ur, _ := models.GetUserRoleFromToken(c) + log.Printf("StoreSecret RoleId was not specified, setting to RoleId of '%d'\n", ur.RoleId) + s.RoleId = ur.RoleId } if input.DeviceCategory == "" && input.DeviceName == "" {