//isAllowed checks if the user is allowed to access device belonging to a given group
isAllowed checks if the user is allowed to access device belonging to a given group
// isAllowed checks if the user is allowed to access device belonging to a given group
func (api *ManagementAPI) isAllowed(
	ctx context.Context, r *http.Request, devID, headerKey string) (bool, error) {
	var err error
	allowed := false
	for _, group := range strings.Split(
		r.Header.Get(headerKey), ",") {
		allowed, err = api.App.AreDevicesInGroup(
			ctx, []string{devID}, group)
		if err != nil {
			return false, err
		}
		if allowed {
			break
		}
	}
	return allowed, nil
}
func ( api * ManagementAPI ) isAllowed ( ctx context . Context , r * http . Request , devID , headerKey string ) ( bool , error ) { var err error allowed := false for _ , group := range strings . Split ( r . Header . Get ( headerKey ) , " " ) { allowed , err = api . App . AreDevicesInGroup ( ctx , [ ] string { devID } , group ) if err != nil { return false , err } if allowed { break } } return allowed , nil }
isAllowed checks if the user is allowed to access device belonging to a given group
isAllowed checks if the user is allowed to access device belonging to a given group