From a91904f18f7788e183b2d939c2e854e4abca988a Mon Sep 17 00:00:00 2001 From: Robin <7434053+warrior_of_light_robin@user.noreply.gitee.com> Date: Tue, 26 Nov 2024 16:28:43 +0800 Subject: [PATCH 1/2] by Robin at 20241126 --- app/mix/service/business_validator/login.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/mix/service/business_validator/login.go b/app/mix/service/business_validator/login.go index af3c5533..e5e6d26c 100644 --- a/app/mix/service/business_validator/login.go +++ b/app/mix/service/business_validator/login.go @@ -124,6 +124,9 @@ func (l *LoginBusinessValidator) EnsureVeriCodeWrongTimesNotReachedDailyUpperbou l.ec = errcode.ErrCodeVeriCodeWrongTimesSrvFail return } + if wrongTimes == nil { + return + } if wrongTimes.WrongTimes >= int64(maxDailyWrongTimes) { logger.Error("wrongs times of verification code of this mid has reached its daily upperbound") From 4a44dd5646e4951ee7a0755be3b9069f44d94973 Mon Sep 17 00:00:00 2001 From: Robin <7434053+warrior_of_light_robin@user.noreply.gitee.com> Date: Tue, 26 Nov 2024 16:28:46 +0800 Subject: [PATCH 2/2] 1 --- app/mix/service/business_validator/login.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/mix/service/business_validator/login.go b/app/mix/service/business_validator/login.go index e5e6d26c..7040e81e 100644 --- a/app/mix/service/business_validator/login.go +++ b/app/mix/service/business_validator/login.go @@ -111,13 +111,6 @@ func (l *LoginBusinessValidator) EnsureVeriCodeWrongTimesNotReachedDailyUpperbou l.oplist = append(l.oplist, func() { if l.login != nil { - // 读取每日错误上限 - maxDailyWrongTimes, err := apollo.GetIntValue(consts.MaxVeriCodeWrongTimesKey, apollo.ApolloOpts().SetNamespace("application")) - if err != nil { - logger.Error("Apollo read failed : %v", err) - l.ec = errcode.ErrCodeApolloReadFail - return - } wrongTimes, err := fun(l.ctx, l.login.GetMid()) if err != nil { @@ -128,6 +121,14 @@ func (l *LoginBusinessValidator) EnsureVeriCodeWrongTimesNotReachedDailyUpperbou return } + // 读取每日错误上限 + maxDailyWrongTimes, err := apollo.GetIntValue(consts.MaxVeriCodeWrongTimesKey, apollo.ApolloOpts().SetNamespace("application")) + if err != nil { + logger.Error("Apollo read failed : %v", err) + l.ec = errcode.ErrCodeApolloReadFail + return + } + if wrongTimes.WrongTimes >= int64(maxDailyWrongTimes) { logger.Error("wrongs times of verification code of this mid has reached its daily upperbound") l.ec = errcode.ErrCodeVeriCodeWrongTimesReachedDailyUpperbound