|
|
@@ -309,7 +309,9 @@ func registerCode(c *gin.Context) {
|
|
|
//发送短信
|
|
|
//sms := sendSms(b, cast.ToString(phone))
|
|
|
//TODO 模拟发送短信
|
|
|
- sms := testSendSms()
|
|
|
+ //sms := testSendSms()
|
|
|
+ email, _ := data("email")
|
|
|
+ sms := testSendMail(cast.ToString(email))
|
|
|
fmt.Println("发送成功!!!:验证码为:", sms)
|
|
|
configs.RedisDb.Set(ctx, "PhoneVerificationCode_"+cast.ToString(phone), sms, 60*5*time.Second)
|
|
|
configs.RedisDb.Set(ctx, "PhoneVerificationCodeTime_"+cast.ToString(phone), time.Now(), 60*time.Second)
|
|
|
@@ -331,6 +333,20 @@ func testSendSms() string {
|
|
|
//}
|
|
|
return randomNum.String()
|
|
|
}
|
|
|
+func testSendMail(email string) string {
|
|
|
+ mins := big.NewInt(100000)
|
|
|
+ maxs := big.NewInt(999999)
|
|
|
+ randomNum := share.RandomInt(mins, maxs)
|
|
|
+ //if matched {
|
|
|
+ // //bools, err = configs.Engine.Table("user").Where("username = ?", username).Exist(&user)
|
|
|
+ //
|
|
|
+ share.SendMail(email, strconv.Itoa(int(randomNum.Int64())))
|
|
|
+ //
|
|
|
+ //} else {
|
|
|
+ // share.SendSms(strconv.Itoa(int(randomNum.Int64())), username)
|
|
|
+ //}
|
|
|
+ return randomNum.String()
|
|
|
+}
|
|
|
|
|
|
func register(c *gin.Context) {
|
|
|
|