Merge remote-tracking branch 'origin/mark' into yonghui
This commit is contained in:
@@ -146,26 +146,48 @@ func init() {
|
||||
auth2.Init(userProvider)
|
||||
}
|
||||
|
||||
func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVerifyCode string, inAuthInfo *auth2.AuthInfo) (outAuthInfo *auth2.AuthInfo, err error) {
|
||||
func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVerifyCode string, inAuthInfo, manTokenInfo *auth2.AuthInfo) (outAuthInfo *auth2.AuthInfo, err error) {
|
||||
var mobileAuth *auth2.AuthInfo
|
||||
fakeMobile := false
|
||||
user.Type = model.UserTypeConsumer
|
||||
createName := ctx.GetRealRemoteIP()
|
||||
authType := auth2.AuthTypeMobile
|
||||
if manTokenInfo != nil && mobileVerifyCode == "" {
|
||||
user, err2 := dao.GetUserByID(dao.GetDB(), "user_id", manTokenInfo.GetID())
|
||||
if err = err2; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if user.Type&(model.UserTypeOperator|model.UserTypeBoss) == 0 {
|
||||
return nil, fmt.Errorf("管理员才能添加商户")
|
||||
}
|
||||
if utils.Pointer2String(user.Mobile) == "" {
|
||||
return nil, fmt.Errorf("管理员添加必须指定用户手机号")
|
||||
}
|
||||
mobileVerifyCode = auth2.InternalAuthSecret
|
||||
fakeMobile = true
|
||||
user.Type |= model.UserTypeStoreBoss
|
||||
createName = manTokenInfo.GetName()
|
||||
}
|
||||
|
||||
if mobileVerifyCode != "" {
|
||||
mobileAuth, err = auth2.Login(ctx.Context, auth2.AuthTypeMobile, user.GetMobile(), auth2.UserIDMobile, mobileVerifyCode)
|
||||
if fakeMobile {
|
||||
mobileAuth, err = auth2.LoginInternal(ctx.Context, auth2.AuthTypeMobile, user.GetMobile(), auth2.UserIDMobile, mobileVerifyCode)
|
||||
} else {
|
||||
mobileAuth, err = auth2.Login(ctx.Context, auth2.AuthTypeMobile, user.GetMobile(), auth2.UserIDMobile, mobileVerifyCode)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if mobileAuth != nil && !mobileAuth.IsUserEmpty() {
|
||||
return nil, jsonerr.New(mobileAuth, model.ErrCodeJsonUserAlreadyExist)
|
||||
}
|
||||
} else {
|
||||
if inAuthInfo == nil {
|
||||
return nil, fmt.Errorf("短信验证码与其它认证方式至少要指定一种")
|
||||
}
|
||||
} else if inAuthInfo != nil {
|
||||
user.Mobile = nil
|
||||
} else {
|
||||
return nil, fmt.Errorf("短信验证码与其它认证方式至少要指定一种")
|
||||
}
|
||||
createName := ctx.GetRealRemoteIP()
|
||||
authType := auth2.AuthTypeMobile
|
||||
|
||||
if inAuthInfo != nil {
|
||||
user.Type = model.UserTypeConsumer
|
||||
if inAuthInfo.AuthBindInfo.Type == dingding.AuthTypeStaff {
|
||||
user.Type |= model.UserTypeOperator
|
||||
} else if user.Mobile != nil {
|
||||
|
||||
Reference in New Issue
Block a user