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 == "" {