This commit is contained in:
mr 2024-12-02 16:59:08 +01:00
parent e2ddd7e4e6
commit 599a614480
2 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package collaborative_area package collaborative_area
import ( import (
"fmt"
"slices" "slices"
"time" "time"
@ -72,6 +73,7 @@ func (ao *CollaborativeArea) Clear(peerID string) {
func (ao *CollaborativeArea) VerifyAuth(peerID string, groups []string) bool { func (ao *CollaborativeArea) VerifyAuth(peerID string, groups []string) bool {
if ao.AllowedPeersGroup != nil || config.GetConfig().Whitelist { if ao.AllowedPeersGroup != nil || config.GetConfig().Whitelist {
if grps, ok := ao.AllowedPeersGroup[peerID]; ok || config.GetConfig().Whitelist { if grps, ok := ao.AllowedPeersGroup[peerID]; ok || config.GetConfig().Whitelist {
fmt.Println("grps", grps, "ok", ok, "config.GetConfig().Whitelist", config.GetConfig().Whitelist)
if slices.Contains(grps, "*") || (!ok && config.GetConfig().Whitelist) { if slices.Contains(grps, "*") || (!ok && config.GetConfig().Whitelist) {
return true return true
} }

View File

@ -213,10 +213,10 @@ func genericLoadAll[T DBObject](res *mgb.Cursor, code int, err error, f func(DBO
return nil, 404, err return nil, 404, err
} }
for _, r := range results { for _, r := range results {
fmt.Println("results", r.VerifyAuth(a.GetPeerID(), a.GetGroups()))
if !r.VerifyAuth(a.GetPeerID(), a.GetGroups()) { if !r.VerifyAuth(a.GetPeerID(), a.GetGroups()) {
continue continue
} }
fmt.Println("results", len(results), f(r))
objs = append(objs, f(r)) objs = append(objs, f(r))
} }
return objs, 200, nil return objs, 200, nil
@ -224,6 +224,7 @@ func genericLoadAll[T DBObject](res *mgb.Cursor, code int, err error, f func(DBO
func GenericLoadAll[T DBObject](f func(DBObject) ShallowDBObject, wfa Accessor) ([]ShallowDBObject, int, error) { func GenericLoadAll[T DBObject](f func(DBObject) ShallowDBObject, wfa Accessor) ([]ShallowDBObject, int, error) {
res_mongo, code, err := mongo.MONGOService.LoadAll(wfa.GetType().String()) res_mongo, code, err := mongo.MONGOService.LoadAll(wfa.GetType().String())
fmt.Println("res_mongo", res_mongo)
return genericLoadAll[T](res_mongo, code, err, f, wfa) return genericLoadAll[T](res_mongo, code, err, f, wfa)
} }