feat:完善入驻信息管理
This commit is contained in:
@ -45,7 +45,7 @@ var loginHandle = map[LoginMode]func(*LoginParams, string) (*InstanceLoginParams
|
||||
// loginForSmsCaptcha 短信验证码登陆
|
||||
func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams, error) {
|
||||
if !utils.ValidateMobile(params.Captcha.Mobile) {
|
||||
return nil, errors.New("手机号码格式异常")
|
||||
return nil, errors.New("操作错误,手机号码格式异常")
|
||||
}
|
||||
pass, err := handle.NewCaptcha().Validate(&handle.CaptchaSms{
|
||||
Mobile: params.Captcha.Mobile, Captcha: params.Captcha.Captcha,
|
||||
@ -53,14 +53,14 @@ func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
return nil, errors.New("验证码错误或已过期")
|
||||
return nil, errors.New("操作错误,验证码错误或已过期")
|
||||
}
|
||||
var isExist bool
|
||||
// 查询账号信息
|
||||
mUserInstance := model3.NewUserInstance()
|
||||
|
||||
if isExist, err = model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "name", "mobile", "status"},
|
||||
model2.NewWhere("mobile", params.Captcha.Mobile), model2.NewWhere("local", local)); err != nil {
|
||||
model2.NewWhere("mobile", params.Captcha.Mobile)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mUserIdentity := model3.NewUserIdentity()
|
||||
@ -72,6 +72,8 @@ func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams
|
||||
}
|
||||
goto RETURNS
|
||||
}
|
||||
mUserInstance.Name = params.Captcha.Mobile
|
||||
mUserInstance.Mobile = params.Captcha.Mobile
|
||||
mUserInstance.Password = utils.GetRandomString(12)
|
||||
|
||||
if err = model2.Create(mUserInstance.UserInstance); err != nil {
|
||||
@ -89,20 +91,20 @@ RETURNS:
|
||||
// loginForPassword 密码登陆
|
||||
func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams, error) {
|
||||
if !utils.ValidateMobile(params.Password.Account) {
|
||||
return nil, errors.New("手机号码格式异常")
|
||||
return nil, errors.New("操作错误,手机号码格式异常")
|
||||
}
|
||||
mUserInstance := model3.NewUserInstance()
|
||||
|
||||
isExist, err := model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "mobile", "password", "salt", "status"},
|
||||
model2.NewWhere("mobile", params.Password.Account), model2.NewWhere("local", local))
|
||||
isExist, err := model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "name", "mobile", "password", "salt", "status"},
|
||||
model2.NewWhere("mobile", params.Password.Account))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if isExist {
|
||||
return nil, errors.New("当前手机号码未注册")
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,当前手机号码未注册")
|
||||
}
|
||||
if !mUserInstance.ValidatePassword(params.Password.Password) {
|
||||
return nil, errors.New("账户或密码错误")
|
||||
return nil, errors.New("操作错误,账户或密码错误")
|
||||
}
|
||||
// 最后一次选中的身份信息
|
||||
mUserIdentity := model3.NewUserIdentity()
|
||||
@ -110,7 +112,6 @@ func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams,
|
||||
if err = mUserIdentity.LastChooseInfo(mUserInstance.UUID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID,
|
||||
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
@ -127,7 +128,7 @@ func (c *Login) Launch(mode LoginMode, params *LoginParams) (*InstanceLoginRetur
|
||||
_handle, has := loginHandle[mode]
|
||||
|
||||
if !has {
|
||||
return nil, errors.New("未知的登陆模式")
|
||||
return nil, errors.New("操作错误,未知的登陆模式")
|
||||
}
|
||||
ret, err := _handle(params, c.local)
|
||||
|
||||
@ -135,7 +136,7 @@ func (c *Login) Launch(mode LoginMode, params *LoginParams) (*InstanceLoginRetur
|
||||
return nil, err
|
||||
}
|
||||
if ret.Status != model2.AccountStatusForEnable {
|
||||
return nil, errors.New("该账号已禁止登陆,请联系管理员")
|
||||
return nil, errors.New("操作错误,该账号已禁止登陆,请联系管理员")
|
||||
}
|
||||
return NewInstance()().Login()(ret), err
|
||||
}
|
||||
|
Reference in New Issue
Block a user