feat:完善信息

This commit is contained in:
henry
2021-10-12 16:53:49 +08:00
parent cf3bc8ffb4
commit eccd71809d
14 changed files with 88 additions and 69 deletions

View File

@ -61,7 +61,7 @@ func (a *Account) Register(c *gin.Context) {
}
func (a *Account) BindMobile() {
account.NewOther()().BindMobile()
//account.NewOther()().BindMobile()
}
func (a *Account) Logout(c *gin.Context) {

View File

@ -1,11 +1,29 @@
package account
import (
"SciencesServer/app/handle"
"SciencesServer/utils"
"errors"
)
type Other struct{}
type OtherHandle func() *Other
func (c *Other) BindMobile() {
// 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
}
func NewOther() OtherHandle {

View File

@ -33,10 +33,12 @@ func (c *RegisterParams) checkUserExist(mUserInstance *model2.UserInstance) (boo
}
return count > 0, nil
}
func (c *RegisterParams) checkCaptcha() (bool, error) {
return handle.NewCaptcha().Validate(&handle.CaptchaSms{Captcha: c.Captcha, Mobile: c.Mobile})
}
// Launch 发起注册
func (c *Register) Launch(params *RegisterParams) (*InstanceLoginReturn, error) {
if params.checkPassword() {
return nil, errors.New("两次密码不一致")