-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
enhancementNew feature or requestNew feature or request
Description
When creating a program, there is a programOwnerID field (user) edge. By default, if this is not set on the mutation, it should default to the user creating the program:
- Add a new
hookto programs: https://github.com/theopenlane/core/blob/main/internal/ent/hooks/program.go - It should:
- Only occur on
OpCreatemutations - It should check if
m.ProgramOwnerID()is set and not an empty string - If it is not set, it should should check
auth.GetAuthzSubjectType(ctx),, if that isauth.UserSubjectTypethen - Get the
SubjectIDusingauth.GetSubjectIDFromContext(ctx) - If that is not an empty string, set
m.SetProgramOwnerID(userID) - continue to next mutation
next.Mutate(ctx, m)
- Only occur on
- Add this hook to the
programsschema and runtask generate
Update program tests:
- Update
Createtests so it checks for a non empty programOwnerID on requests done by JWT or Personal Access tokens, and that it is empty on requests done with the api client. - You will need to update the testclient query before updating the tests to add the
programOwnerIDfield. After adding, you'll need to runtask generate:gql
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request