add username to our trip

This commit is contained in:
mr
2024-12-04 11:33:08 +01:00
parent 6681c455d8
commit fd01f535a1
30 changed files with 129 additions and 113 deletions

View File

@@ -98,15 +98,15 @@ type Workflow struct {
AbstractWorkflow // AbstractWorkflow contains the basic fields of a workflow
}
func (ao *Workflow) VerifyAuth(peerID string, groups []string) bool {
func (ao *Workflow) VerifyAuth(username string, peerID string, groups []string) bool {
isAuthorized := false
if len(ao.Shared) > 0 {
for _, shared := range ao.Shared {
shared, code, _ := shallow_collaborative_area.New(tools.COLLABORATIVE_AREA, peerID, groups, nil).LoadOne(shared)
shared, code, _ := shallow_collaborative_area.New(tools.COLLABORATIVE_AREA, username, peerID, groups, nil).LoadOne(shared)
if code != 200 || shared == nil {
isAuthorized = false
}
isAuthorized = shared.VerifyAuth(peerID, groups)
isAuthorized = shared.VerifyAuth(username, peerID, groups)
}
} else {
isAuthorized = true
@@ -122,7 +122,7 @@ func (wfa *Workflow) CheckBooking(caller *tools.HTTPCaller) (bool, error) {
if wfa.Graph == nil { // no graph no booking
return false, nil
}
accessor := (&resources.ComputeResource{}).GetAccessor("", []string{}, caller)
accessor := (&resources.ComputeResource{}).GetAccessor("", "", []string{}, caller)
for _, link := range wfa.Graph.Links {
if ok, dc_id := wfa.isDCLink(link); ok { // check if the link is a link between a compute and a resource
dc, code, _ := accessor.LoadOne(dc_id)
@@ -143,6 +143,6 @@ func (wfa *Workflow) CheckBooking(caller *tools.HTTPCaller) (bool, error) {
return true, nil
}
func (d *Workflow) GetAccessor(peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
return New(tools.WORKFLOW, peerID, groups, caller) // Create a new instance of the accessor
func (d *Workflow) GetAccessor(username string, peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
return New(tools.WORKFLOW, username, peerID, groups, caller) // Create a new instance of the accessor
}