From ef9ad22841cecd71ee41753dc0a3e37a968a3787 Mon Sep 17 00:00:00 2001 From: "n.nakhostin" Date: Mon, 22 Sep 2025 11:57:19 +0330 Subject: [PATCH] Refactor Customer Repository Login Method to Simplify Device Token Handling - Removed the use of the slices package for checking existing device tokens during customer login. - Updated the Login method to directly assign the device token to the customer, ensuring a more straightforward approach to managing device tokens. - Enhanced code readability by eliminating unnecessary checks, streamlining the login process for customers. --- internal/customer/repository.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/customer/repository.go b/internal/customer/repository.go index 7cba42e..6de48eb 100644 --- a/internal/customer/repository.go +++ b/internal/customer/repository.go @@ -3,7 +3,6 @@ package customer import ( "context" "errors" - "slices" "time" "tm/pkg/logger" orm "tm/pkg/mongo" @@ -99,9 +98,9 @@ func (r *customerRepository) Login(ctx context.Context, id, deviceToken string) } // append device token to customer if not exists - if !slices.Contains(customer.DeviceToken, deviceToken) { - customer.DeviceToken = append(customer.DeviceToken, deviceToken) - } + // if !slices.Contains(customer.DeviceToken, deviceToken) { + customer.DeviceToken = []string{deviceToken} + // } // Update last login timestamp customer.LastLoginAt = &[]int64{time.Now().Unix()}[0]