iedc-go/app/sms.go

34 lines
792 B
Go
Raw Permalink Normal View History

2022-10-30 15:44:05 +00:00
package app
import (
2022-10-30 17:18:19 +00:00
. "code.hoteas.com/golang/hotime"
"code.hoteas.com/golang/hotime/dri/ddsms"
2022-10-30 15:44:05 +00:00
)
var Sms = Ctr{
//只允许微信验证过的或者登录成功的发送短信
"send": func(this *Context) {
//if this.Session("uid").Data == nil && this.Session("wechatInfo").Data == nil {
// this.Display(2, "没有授权")
// return
//}
//if len(this.Req.FormValue("token")) != 32 {
// this.Display(2, "没有授权")
// return
//}
phone := this.Req.FormValue("phone")
if len(phone) < 11 {
this.Display(3, "手机号格式错误")
return
}
code := getCode()
this.Session("phone", phone)
this.Session("code", code)
2022-10-30 17:18:19 +00:00
ddsms.DDY.SendYZM(phone, this.Config.GetString("smsLogin"), map[string]string{"code": code})
2022-10-30 15:44:05 +00:00
this.Display(0, "发送成功")
},
}