Files

34 lines
664 B
Go
Raw Normal View History

2021-09-29 16:25:56 +08:00
package account
2021-10-12 16:53:49 +08:00
import (
"SciencesServer/app/handle"
"SciencesServer/utils"
"errors"
)
2021-09-29 16:25:56 +08:00
type Other struct{}
type OtherHandle func() *Other
2021-10-12 16:53:49 +08:00
// BindMobile 绑定手机号码
func (c *Other) BindMobile(token, mobile, captcha string) (interface{}, error) {
if !utils.ValidateMobile(mobile) {
return nil, errors.New("手机号码格式异常")
}
pass, err := handle.NewCaptcha().Validate(&handle.CaptchaSms{
Mobile: mobile, Captcha: captcha,
})
if err != nil {
return nil, err
} else if !pass {
return nil, errors.New("验证码错误或已过期")
}
return nil, nil
2021-09-29 16:25:56 +08:00
}
func NewOther() OtherHandle {
return func() *Other {
return &Other{}
}
}