校验修复以及查询修复
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m55s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m55s
This commit is contained in:
@@ -34,7 +34,7 @@ const (
|
|||||||
assetTokenExpireSeconds = 300
|
assetTokenExpireSeconds = 300
|
||||||
)
|
)
|
||||||
|
|
||||||
var identifierRegex = regexp.MustCompile(`^[A-Za-z0-9-]{1,50}$`)
|
var identifierRegex = regexp.MustCompile(`^[A-Za-z0-9_-]{1,50}$`)
|
||||||
|
|
||||||
// Service C 端认证服务
|
// Service C 端认证服务
|
||||||
type Service struct {
|
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 {
|
if bound, checkErr := s.checkCardBoundToDevice(ctx, assetID); checkErr != nil {
|
||||||
return nil, checkErr
|
return nil, checkErr
|
||||||
} else if bound {
|
} 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) {
|
func (s *Service) resolveAsset(ctx context.Context, identifier string) (string, uint, error) {
|
||||||
var card model.IotCard
|
var card model.IotCard
|
||||||
if err := s.db.WithContext(ctx).
|
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 {
|
First(&card).Error; err == nil {
|
||||||
return assetTypeIotCard, card.ID, nil
|
return assetTypeIotCard, card.ID, nil
|
||||||
} else if err != gorm.ErrRecordNotFound {
|
} else if err != gorm.ErrRecordNotFound {
|
||||||
@@ -416,7 +416,7 @@ func (s *Service) resolveAsset(ctx context.Context, identifier string) (string,
|
|||||||
|
|
||||||
var device model.Device
|
var device model.Device
|
||||||
if err := s.db.WithContext(ctx).
|
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 {
|
First(&device).Error; err == nil {
|
||||||
return assetTypeDevice, device.ID, nil
|
return assetTypeDevice, device.ID, nil
|
||||||
} else if err != gorm.ErrRecordNotFound {
|
} else if err != gorm.ErrRecordNotFound {
|
||||||
|
|||||||
Reference in New Issue
Block a user