diff --git a/service/user/user.go b/service/user/user.go index 4e3f59c..b9ac144 100644 --- a/service/user/user.go +++ b/service/user/user.go @@ -8,7 +8,6 @@ import ( common "git.echol.cn/loser/lckt/model/common/request" "git.echol.cn/loser/lckt/model/user" "git.echol.cn/loser/lckt/model/user/request" - "git.echol.cn/loser/lckt/utils/sms" "go.uber.org/zap" "golang.org/x/crypto/bcrypt" "math/rand" @@ -36,18 +35,19 @@ func (u *UserService) SendCode(req request.SendCodeReq) (err error) { result, err := rdb.Get(context.Background(), key).Result() if result != "" { global.GVA_LOG.Error("验证码发送过于频繁", zap.String("phone", req.Phone)) + err = fmt.Errorf("验证码发送过于频繁,请稍后再试") return } rand.New(rand.NewSource(time.Now().UnixNano())) verifyCode := fmt.Sprintf("%06v", rand.Int31n(1000000)) - if ok := sms.SendSMS(req.Phone, verifyCode); !ok { - global.GVA_LOG.Error("发送验证码失败") - return - } + //if ok := sms.SendSMS(req.Phone, verifyCode); !ok { + // global.GVA_LOG.Error("发送验证码失败") + // return + //} // - if err = rdb.Set(context.Background(), key, verifyCode, time.Duration(global.GVA_CONFIG.SMS.ExpireTime)*time.Second).Err(); err != nil { + if err = rdb.Set(context.Background(), key, verifyCode, 5*time.Minute).Err(); err != nil { global.GVA_LOG.Error("设置验证码缓存失败", zap.Error(err)) return }