Load One pb

This commit is contained in:
mr
2026-04-22 11:47:08 +02:00
parent c208e2ccef
commit 51e2dcc404

View File

@@ -162,9 +162,6 @@ func GenericUpdateOne(change map[string]interface{}, id string, a Accessor) (DBO
} }
func GenericLoadOne[T DBObject](id string, data T, f func(DBObject) (DBObject, int, error), a Accessor) (DBObject, int, error) { func GenericLoadOne[T DBObject](id string, data T, f func(DBObject) (DBObject, int, error), a Accessor) (DBObject, int, error) {
if a.ShouldVerifyAuth() && !data.VerifyAuth("get", a.GetRequest()) {
return nil, 403, errors.New("you are not allowed to access :" + a.GetType().String())
}
res_mongo, code, err := mongo.MONGOService.LoadOne(id, a.GetType().String()) res_mongo, code, err := mongo.MONGOService.LoadOne(id, a.GetType().String())
if err != nil { if err != nil {
return nil, code, err return nil, code, err
@@ -172,7 +169,9 @@ func GenericLoadOne[T DBObject](id string, data T, f func(DBObject) (DBObject, i
if err = res_mongo.Decode(data); err != nil { if err = res_mongo.Decode(data); err != nil {
return nil, 400, err return nil, 400, err
} }
if a.ShouldVerifyAuth() && !data.VerifyAuth("get", a.GetRequest()) {
return nil, 403, errors.New("you are not allowed to access :" + a.GetType().String())
}
return f(data) return f(data)
} }