diff --git a/models/utils/common.go b/models/utils/common.go index 118fe89..fe68aae 100755 --- a/models/utils/common.go +++ b/models/utils/common.go @@ -133,7 +133,10 @@ func GenericLoadOne[T DBObject](id string, data T, f func(DBObject) (DBObject, i return nil, code, err } fmt.Println("APPLY", data, res_mongo) - res_mongo.Decode(&data) + if err = res_mongo.Decode(&data); err == nil { + 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()) }