diff options
Diffstat (limited to 'item/controller.go')
-rw-r--r-- | item/controller.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/item/controller.go b/item/controller.go index cf9683d..9993688 100644 --- a/item/controller.go +++ b/item/controller.go @@ -116,6 +116,7 @@ func handleDelBrand (ctx *gin.Context) { var brand Brand brand.ID = uint(id) + uId, ok := ctx.Get("UserID") if !ok { ctx.Error(e.ErrUnauthorized) @@ -126,6 +127,13 @@ func handleDelBrand (ctx *gin.Context) { userId := uId.(uint) brand.UserID = userId + err = checkBrandOwnership(brand.ID, brand.UserID) + if err != nil { + ctx.Error(err) + ctx.Abort() + return + } + err = brand.del() if err != nil { ctx.Error(err) @@ -210,6 +218,13 @@ func handleDelItem (ctx *gin.Context) { userId := uId.(uint) item.UserID = userId + err = checkItemOwnership(item.ID, item.UserID) + if err != nil { + ctx.Error(err) + ctx.Abort() + return + } + err = item.del() if err != nil { ctx.Error(err) |