- set correct authIDType when calling auth2.Login
This commit is contained in:
@@ -120,9 +120,9 @@ func CreateAuthInfo(user IUser, authBindInfo *model.AuthBind, userData interface
|
||||
UserData: userData,
|
||||
}
|
||||
if user != nil {
|
||||
globals.SugarLogger.Debugf("CreateAuthInfo id:%s, id2:%s, authBindInfo:%s, authInfo:%s", authInfo.GetID(), authInfo.GetID2(), authInfo.GetMobile(), utils.Format4Output(authBindInfo, true), utils.Format4Output(authInfo, true))
|
||||
globals.SugarLogger.Debugf("CreateAuthInfo id:%s, id2:%s, authInfo:%s", authInfo.GetID(), authInfo.GetID2(), authInfo.GetMobile(), utils.Format4Output(authInfo, true))
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("CreateAuthInfo authBindInfo:%s, authInfo:%s", utils.Format4Output(authBindInfo, true), utils.Format4Output(authInfo, true))
|
||||
globals.SugarLogger.Debugf("CreateAuthInfo authInfo:%s", utils.Format4Output(authInfo, true))
|
||||
}
|
||||
SetUserInfo(token, authInfo, DefTokenDuration)
|
||||
return authInfo
|
||||
@@ -163,6 +163,8 @@ func SendVerifyCode(authToken, captchaID, captchaValue, authID string) (err erro
|
||||
}
|
||||
|
||||
// 账号密码时:authIDType可能是:UserIDID,UserIDID2,UserIDMobile,UserIDEmail,authSecret是密码的sha1
|
||||
// mobile或email登录时,authIDType必须相应为UserIDMobile,UserIDEmail
|
||||
// 其它登录时authIDType无用
|
||||
// 邮箱时(如果允许):authIDType是:UserIDEmail,authSecret是验证码的sha1
|
||||
// 手机时(如果允许):authIDType是:UserIDMobile,authSecret是验证码的sha1
|
||||
// 公众号登录:authIDTypeD是UserIDEmpty,authSecret是code(这个函数是被微信的回调调用,不是直接被客户端调用)
|
||||
|
||||
@@ -44,7 +44,7 @@ func RegisterUser(user *model.User, mobileVerifyCode string, inAuthInfo *auth2.A
|
||||
if user == nil || user.UserID2 == "" || user.Name == "" || user.Mobile == "" {
|
||||
return nil, model.ErrCodeGeneralFailed, ErrUserIDAndNameMustGiven
|
||||
}
|
||||
mobileAuth, err2 := auth2.Login(auth2.AuthTypeMobile, user.Mobile, auth2.UserIDNone, mobileVerifyCode)
|
||||
mobileAuth, err2 := auth2.Login(auth2.AuthTypeMobile, user.Mobile, auth2.UserIDMobile, mobileVerifyCode)
|
||||
if err = err2; err == nil {
|
||||
if mobileAuth.IUser != nil {
|
||||
return nil, model.ErrCodeUserAlreadyExist, auth2.ErrUserMobileAlreadyExist
|
||||
@@ -78,7 +78,7 @@ func GetUserBindAuthInfo(ctx *jxcontext.Context) (authList []*model.AuthBind, er
|
||||
func ChangeMobile2(ctx *jxcontext.Context, mobile, mobileVerifyCode string) (err error) {
|
||||
authInfo, err := ctx.GetV2AuthInfo()
|
||||
if err == nil {
|
||||
mobileAuth, err2 := auth2.Login(auth2.AuthTypeMobile, mobile, auth2.UserIDNone, mobileVerifyCode)
|
||||
mobileAuth, err2 := auth2.Login(auth2.AuthTypeMobile, mobile, auth2.UserIDMobile, mobileVerifyCode)
|
||||
if err = err2; err == nil {
|
||||
if mobileAuth.IUser != nil && authInfo.GetID() != mobileAuth.GetID() {
|
||||
return errors.New("手机号已经存在")
|
||||
|
||||
@@ -60,6 +60,11 @@ func (c *Auth2Controller) SendVerifyCode() {
|
||||
// @router /Login [post]
|
||||
func (c *Auth2Controller) Login() {
|
||||
c.callLogin(func(params *tAuth2LoginParams) (retVal interface{}, errCode string, err error) {
|
||||
if params.AuthType == auth2.AuthTypeMobile {
|
||||
params.AuthIDType = auth2.UserIDMobile
|
||||
} else if params.AuthType == auth2.AuthTypeEmail {
|
||||
params.AuthIDType = auth2.UserIDEmail
|
||||
}
|
||||
retVal, err = auth2.Login(params.AuthType, params.AuthID, params.AuthIDType, params.AuthSecret)
|
||||
return retVal, "", err
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user