This commit is contained in:
@@ -66,8 +66,8 @@ func (l *BindEmailWithVerificationLogic) BindEmailWithVerification(req *types.Bi
|
||||
if err := json.Unmarshal([]byte(value), &p); err != nil {
|
||||
continue
|
||||
}
|
||||
// 校验验证码及有效期(10分钟)
|
||||
if p.Code == req.Code && time.Now().Unix()-p.LastAt <= 600 {
|
||||
// 校验验证码及有效期(15分钟)
|
||||
if p.Code == req.Code && time.Now().Unix()-p.LastAt <= 900 {
|
||||
_ = l.svcCtx.Redis.Del(l.ctx, cacheKey).Err()
|
||||
verified = true
|
||||
break
|
||||
|
||||
@@ -50,8 +50,11 @@ func (l *VerifyEmailLogic) VerifyEmail(req *types.VerifyEmailRequest) error {
|
||||
l.Errorw("Redis Error", logger.Field("error", err.Error()), logger.Field("cacheKey", cacheKey))
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.VerifyCodeError), "code error")
|
||||
}
|
||||
if payload.Code != req.Code || time.Now().Unix()-payload.LastAt > 600 {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.VerifyCodeError), "code error or expired")
|
||||
if payload.Code != req.Code { // 校验有效期(15分钟)
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.VerifyCodeError), "code error")
|
||||
}
|
||||
if time.Now().Unix()-payload.LastAt > 900 {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.VerifyCodeError), "code expired")
|
||||
}
|
||||
l.svcCtx.Redis.Del(l.ctx, cacheKey)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user