|
|
@ -8,6 +8,7 @@ import (
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
redigo "github.com/gomodule/redigo/redis"
|
|
|
|
redigo "github.com/gomodule/redigo/redis"
|
|
|
|
|
|
|
|
"regexp"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type SsoSendSmsCodeParams struct {
|
|
|
|
type SsoSendSmsCodeParams struct {
|
|
|
@ -27,6 +28,12 @@ func SsoSendSmsCode(a *dapi.ApiBase, params *SsoSendSmsCodeParams) error {
|
|
|
|
redisCodeKey := fmt.Sprintf("smscode:%s", params.Mobile)
|
|
|
|
redisCodeKey := fmt.Sprintf("smscode:%s", params.Mobile)
|
|
|
|
redisDailyKey := fmt.Sprintf("smscode_daily:%s", params.Mobile)
|
|
|
|
redisDailyKey := fmt.Sprintf("smscode_daily:%s", params.Mobile)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mobileRegex := `^1[3-9]\d{9}$`
|
|
|
|
|
|
|
|
matched, err := regexp.MatchString(mobileRegex, params.Mobile)
|
|
|
|
|
|
|
|
if err != nil || !matched {
|
|
|
|
|
|
|
|
return a.ReturnPublicErrorResponse(a.Translate("invalid_mobile"))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
conn := redis.RPool.Get()
|
|
|
|
conn := redis.RPool.Get()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
if err := conn.Close(); err != nil {
|
|
|
|
if err := conn.Close(); err != nil {
|
|
|
|