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.
This commit is contained in:
n.nakhostin
2025-09-22 11:57:19 +03:30
parent ddf4d9abc4
commit ef9ad22841
+3 -4
View File
@@ -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]