修改获取验证码
This commit is contained in:
parent
8d4bb9bbf8
commit
c6bb1d0840
@ -50,7 +50,7 @@ func (r *Login) Login(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
code, _ := global.Redis.Get(c, "login_code_count_"+req.Mobile).Result()
|
code, _ := global.Redis.Get(c, "login_code_"+req.Mobile).Result()
|
||||||
if code == "" {
|
if code == "" {
|
||||||
responses.FailWithMessage("验证码失效", c)
|
responses.FailWithMessage("验证码失效", c)
|
||||||
return
|
return
|
||||||
@ -64,6 +64,7 @@ func (r *Login) Login(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return
|
||||||
// 开始事务
|
// 开始事务
|
||||||
tx := global.Db.Begin()
|
tx := global.Db.Begin()
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|||||||
@ -18,7 +18,7 @@ type PublicService struct {
|
|||||||
|
|
||||||
// GetPhoneCode 获取手机验证码
|
// GetPhoneCode 获取手机验证码
|
||||||
func (r *PublicService) GetPhoneCode(scene int, phone string) (bool, error) {
|
func (r *PublicService) GetPhoneCode(scene int, phone string) (bool, error) {
|
||||||
var sendCodeCount int // // 获取验证码最大次数
|
sendCodeCount := 1 // // 获取验证码最大次数
|
||||||
var code string // 验证码
|
var code string // 验证码
|
||||||
var templateCode string // 短信模版
|
var templateCode string // 短信模版
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ func (r *PublicService) GetPhoneCode(scene int, phone string) (bool, error) {
|
|||||||
|
|
||||||
// 记录发送次数
|
// 记录发送次数
|
||||||
if sendCodeCount != 0 {
|
if sendCodeCount != 0 {
|
||||||
_, err = global.Redis.Set(context.Background(), "login_code_count_"+phone, time.Now().Unix(), 60*5*time.Second).Result()
|
_, err = global.Redis.Set(context.Background(), "login_code_count_"+phone, sendCodeCount, 60*5*time.Second).Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.New("验证码发送失败,请您稍后再试")
|
return false, errors.New("验证码发送失败,请您稍后再试")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user