fix:验证码问题

master
howell 3 years ago
parent 7008680aaa
commit 221968c6cb

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

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

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

Loading…
Cancel
Save