fix:验证码问题

master
howell 3 years ago
parent 7008680aaa
commit 221968c6cb

@ -67,16 +67,16 @@ func GetUserDestroySMSCode(user uint) string {
return v return v
} }
func SetUpgradeSMSCode(user uint, code string) { func SetUpgradeSMSCode(user uint, mobile, code string) {
k := fmt.Sprintf("sms:upgrade:%v", user) k := fmt.Sprintf("sms:upgrade:%s:%v", mobile, user)
e := dbc.Rds.Set(k, code, time.Minute*10).Err() e := dbc.Rds.Set(k, code, time.Minute*10).Err()
if e != nil { if e != nil {
panic(e) panic(e)
} }
} }
func GetUpgradeSMSCode(user uint) string { func GetUpgradeSMSCode(user uint, mobile string) string {
k := fmt.Sprintf("sms:upgrade:%v", user) k := fmt.Sprintf("sms:upgrade:%s:%v", mobile, user)
v, err := dbc.Rds.Get(k).Result() v, err := dbc.Rds.Get(k).Result()
if err == redis.Nil { if err == redis.Nil {
return "" return ""

@ -91,7 +91,7 @@ func (o Proxy) Send(c *gin.Context) {
} }
if response.IsSuccess() { if response.IsSuccess() {
cache.SetUpgradeSMSCode(u.Id, randString) cache.SetUpgradeSMSCode(u.Id, args.Mobile, randString)
var p message.AliResp var p message.AliResp
if err = json.Unmarshal(response.GetHttpContentBytes(), &p); err != nil { if err = json.Unmarshal(response.GetHttpContentBytes(), &p); err != nil {

@ -87,7 +87,7 @@ func (o logic) Create(args ApplyCreate) error {
// if args.Kind == 1 { // if args.Kind == 1 {
// state = upgrade.Suc // state = upgrade.Suc
// } // }
if args.Code != cache.GetUpgradeSMSCode(u1.Id) { if args.Code != cache.GetUpgradeSMSCode(u1.Id, args.Mobile) {
return fmt.Errorf("验证码不正确") return fmt.Errorf("验证码不正确")
} }
if err := mysql.Db.Transaction(func(tx *gorm.DB) error { if err := mysql.Db.Transaction(func(tx *gorm.DB) error {

Loading…
Cancel
Save