aboutsummaryrefslogtreecommitdiff
path: root/customer/controller.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2023-09-03 22:02:56 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2023-09-03 22:02:56 +0530
commitc6bc8d0c6d1c1ab5d26b9e47e0248002d22ecf8f (patch)
treea80b66210b6f45aaa8b3c0c39baeda451b38f765 /customer/controller.go
parent6922e09f46a24b7bd70db5e78ab1c4a77e59303c (diff)
moved contact details to customer model for simplicity
Diffstat (limited to 'customer/controller.go')
-rw-r--r--customer/controller.go9
1 files changed, 7 insertions, 2 deletions
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)