From c6bc8d0c6d1c1ab5d26b9e47e0248002d22ecf8f Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 3 Sep 2023 22:02:56 +0530 Subject: moved contact details to customer model for simplicity --- customer/controller.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'customer/controller.go') diff --git a/customer/controller.go b/customer/controller.go index ae6101f..2bacd02 100644 --- a/customer/controller.go +++ b/customer/controller.go @@ -99,7 +99,6 @@ func handleSaveCustomer (ctx *gin.Context) { userId := uId.(uint) customer.UserID = userId - customer.Contact.UserID = userId err := customer.upsert() if err != nil { @@ -134,7 +133,13 @@ func handleDelCustomer (ctx *gin.Context) { userId := uId.(uint) customer.UserID = userId - // TODO: if userid and customer's user id don't match, dont delete + err = checkCustomerOwnership(customer.ID, customer.UserID) + if err != nil { + ctx.Error(err) + ctx.Abort() + return + } + err = customer.del() if err != nil { ctx.Error(err) -- cgit v1.2.3