Skip to content

Commit

Permalink
also show event asp events as crew asp
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiKaestle committed Dec 11, 2024
1 parent ebc381b commit 62db4f1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions models/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,12 @@ func (i *EventUpdate) PermittedFilter(token *AccessToken) bson.D {
filter.EqualString("_id", i.ID)
if !(token.Roles.Validate("admin;employee;pool_employee") || token.PoolRoles.Validate(ASPEventRole)) {
filter.EqualString("event_asp_id", token.ID)
filter.EqualString("crew_id", token.CrewID)
} else if !token.Roles.Validate("admin;employee;pool_employee") {
filter.EqualString("crew_id", token.CrewID)
crewMatch := vmdb.NewFilter()
crewMatch.EqualString("crew_id", token.CrewID)
eventAspMatch := vmdb.NewFilter()
eventAspMatch.EqualString("event_asp_id", token.ID)
filter.Append(bson.E{Key: "$or", Value: bson.A{eventAspMatch.Bson(), crewMatch.Bson()}})
}
return filter.Bson()
}
Expand All @@ -534,8 +537,13 @@ func (i *EventParam) PermittedFilter(token *AccessToken) bson.D {
if !(token.Roles.Validate("admin;employee;pool_employee") || token.PoolRoles.Validate(ASPEventRole)) {
filter.EqualString("event_asp_id", token.ID)
} else if !token.Roles.Validate("admin;employee;pool_employee") {
filter.EqualString("crew_id", token.CrewID)
crewMatch := vmdb.NewFilter()
crewMatch.EqualString("crew_id", token.CrewID)
eventAspMatch := vmdb.NewFilter()
eventAspMatch.EqualString("event_asp_id", token.ID)
filter.Append(bson.E{Key: "$or", Value: bson.A{eventAspMatch.Bson(), crewMatch.Bson()}})
}

return filter.Bson()
}

Expand Down

0 comments on commit 62db4f1

Please sign in to comment.