M api/graph/resolver.go => api/graph/resolver.go +5 -3
@@ 66,7 66,7 @@ func FetchLogs(ctx context.Context, url string) (*model.Log, error) {
}
// Starts a job group. Does not authenticate the user.
-func StartJobGroupUnsafe(ctx context.Context, tx *sql.Tx, id int) error {
+func StartJobGroupUnsafe(ctx context.Context, tx *sql.Tx, id, ownerID int) error {
var manifests []struct {
ID int
Manifest *Manifest
@@ 74,9 74,11 @@ func StartJobGroupUnsafe(ctx context.Context, tx *sql.Tx, id int) error {
rows, err := tx.QueryContext(ctx, `
UPDATE job SET status = 'queued'
- WHERE job_group_id = $1
+ WHERE
+ job_group_id = $1 AND
+ owner_id = $2
RETURNING id, manifest;
- `, id)
+ `, id, ownerID)
if err != nil {
return err
}
M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +2 -2
@@ 540,7 540,7 @@ func (r *mutationResolver) CreateGroup(ctx context.Context, jobIds []int, trigge
return nil
}
- return StartJobGroupUnsafe(ctx, tx, group.ID)
+ return StartJobGroupUnsafe(ctx, tx, group.ID, group.OwnerID)
}); err != nil {
return nil, err
}
@@ 566,7 566,7 @@ func (r *mutationResolver) StartGroup(ctx context.Context, groupID int) (*model.
return err
}
- return StartJobGroupUnsafe(ctx, tx, groupID)
+ return StartJobGroupUnsafe(ctx, tx, groupID, group.OwnerID)
}); err != nil {
return nil, err
}