This commit is contained in:
wucongxing8150 2024-07-29 11:59:01 +08:00
parent 5a94972228
commit 502908b4e5
3 changed files with 14 additions and 1 deletions

View File

@ -32,6 +32,18 @@ func (r *Login) LoginPhone(c *gin.Context) {
return
}
// 检测验证码
code, _ := global.Redis.Get(c, "login_code_count_"+req.Mobile).Result()
if code == "" {
responses.FailWithMessage("验证码失效", c)
return
}
if req.Code != code {
responses.FailWithMessage("验证码错误", c)
return
}
// 检测用户信息
userDao := dao.UserDao{}
maps := make(map[string]interface{})

View File

@ -15,6 +15,7 @@ type LoginWx struct {
// LoginPhone 手机号登录
type LoginPhone struct {
Mobile string `json:"mobile" form:"mobile" label:"手机号" validate:"required"`
Code string `json:"code" form:"code" label:"手机号" validate:"required"`
Source int `json:"source" form:"source" label:"来源)" validate:"required"` // 1app 2公众号
LoginIp string `json:"login_ip" form:"login_ip" label:"登录ip"`
}

View File

@ -68,7 +68,7 @@ func (r *PublicService) GetPhoneCode(scene int, phone string) (bool, error) {
}
// 设置验证码有效期
_, err = global.Redis.Set(context.Background(), "login_code_"+phone, code, 60*30*time.Second).Result()
_, err = global.Redis.Set(context.Background(), "login_code_"+phone, code, 60*5*time.Second).Result()
if err != nil {
return false, errors.New("验证码发送失败,请您稍后再试")
}