From 3f2cf3154324f24199b7b82be5483fdc107588e2 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 24 Apr 2026 09:41:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E4=BF=AE=E5=A4=8D=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E6=9F=A5=E8=AF=A2=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/service/client_auth/service.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/client_auth/service.go b/internal/service/client_auth/service.go index 71b8100..60d4b48 100644 --- a/internal/service/client_auth/service.go +++ b/internal/service/client_auth/service.go @@ -34,7 +34,7 @@ const ( assetTokenExpireSeconds = 300 ) -var identifierRegex = regexp.MustCompile(`^[A-Za-z0-9-]{1,50}$`) +var identifierRegex = regexp.MustCompile(`^[A-Za-z0-9_-]{1,50}$`) // Service C 端认证服务 type Service struct { @@ -112,7 +112,7 @@ func (s *Service) VerifyAsset(ctx context.Context, req *dto.VerifyAssetRequest, if bound, checkErr := s.checkCardBoundToDevice(ctx, assetID); checkErr != nil { return nil, checkErr } else if bound { - return nil, errors.New(errors.CodeForbidden, "该卡绑定了设备,请使用设备的虚拟号/设备号/IEMI/SN登录") + return nil, errors.New(errors.CodeForbidden, "该卡绑定了设备,请使用设备的虚拟号/设备号/IMEI/SN登录") } } @@ -407,7 +407,7 @@ func (s *Service) checkAssetVerifyRateLimit(ctx context.Context, clientIP string func (s *Service) resolveAsset(ctx context.Context, identifier string) (string, uint, error) { var card model.IotCard if err := s.db.WithContext(ctx). - Where("iccid = ? OR virtual_no = ?", identifier, identifier). + Where("iccid = ? OR virtual_no = ? OR msisdn = ?", identifier, identifier, identifier). First(&card).Error; err == nil { return assetTypeIotCard, card.ID, nil } else if err != gorm.ErrRecordNotFound { @@ -416,7 +416,7 @@ func (s *Service) resolveAsset(ctx context.Context, identifier string) (string, var device model.Device if err := s.db.WithContext(ctx). - Where("virtual_no = ? OR imei = ?", identifier, identifier). + Where("virtual_no = ? OR imei = ? OR sn = ?", identifier, identifier, identifier). First(&device).Error; err == nil { return assetTypeDevice, device.ID, nil } else if err != gorm.ErrRecordNotFound {