add authBind
This commit is contained in:
@@ -253,7 +253,6 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string
|
||||
globals.SugarLogger.Debugf("Login authBindEx", utils.Format4Output(authBindEx, false))
|
||||
if authBindEx == nil { // mobile, email会返回nil(表示不会新建AuthBind实体)
|
||||
user = userProvider.GetUser(authID, authIDType)
|
||||
globals.SugarLogger.Debug("user第一次===================", user)
|
||||
authBindEx = &AuthBindEx{
|
||||
AuthBind: model.AuthBind{
|
||||
Type: authType,
|
||||
@@ -264,7 +263,6 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string
|
||||
} else {
|
||||
// 返回authBind中UserID为空表示只是认证,但本地没有记录,这种情况会返回临时TOKEN
|
||||
if authBindEx.UserHint != nil && authBindEx.UserID == "" {
|
||||
globals.SugarLogger.Debug("进入")
|
||||
// 利用得到受信任的信息查找用户
|
||||
if authBindEx.UserHint.Mobile != "" {
|
||||
user = userProvider.GetUser(authBindEx.UserHint.Mobile, UserIDMobile)
|
||||
@@ -278,18 +276,12 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string
|
||||
if user2 := userProvider.GetUser(authBindEx.UserHint.Email, UserIDMobile); user2 != nil {
|
||||
user = user2
|
||||
}
|
||||
globals.SugarLogger.Debug("user检测1=============", user)
|
||||
} else if authBindEx.UserID != "" {
|
||||
user = userProvider.GetUser(authBindEx.UserID, UserIDID)
|
||||
globals.SugarLogger.Debug("user检测2=============", user)
|
||||
}
|
||||
globals.SugarLogger.Debug("user第二次=============", user)
|
||||
}
|
||||
globals.SugarLogger.Debug("输出authBindEx,user", authBindEx, user)
|
||||
authInfo = createAuthInfo(user, authBindEx)
|
||||
globals.SugarLogger.Debug("输出authInfo", authInfo)
|
||||
if user != nil && user.GetID() != "" {
|
||||
globals.SugarLogger.Debug("我进入到user != nil && user.GetID()")
|
||||
userProvider.UpdateLastLogin(user.GetID(), authType, ctx.GetRealRemoteIP())
|
||||
}
|
||||
//如果是小程序
|
||||
@@ -317,12 +309,10 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string
|
||||
} else {
|
||||
err = ErrIllegalAuthType
|
||||
}
|
||||
globals.SugarLogger.Debug("我到最末端了===========================")
|
||||
return authInfo, err
|
||||
}
|
||||
|
||||
func Login(ctx *Context, authType, authID, authIDType, authSecret string) (authInfo *AuthInfo, err error) {
|
||||
globals.SugarLogger.Debug("我进入login了===========================")
|
||||
if authSecret == InternalAuthSecret {
|
||||
authSecret = ""
|
||||
}
|
||||
@@ -368,11 +358,9 @@ func DecryptUserMsg(sessionKey, iv, msg string) (string, error) {
|
||||
// 通过临时TOKEN绑定新创建的用户
|
||||
func BindUser(inauthInfo *AuthInfo, user IUser) (outauthInfo *AuthInfo, err error) {
|
||||
if err = AddAuthBind(user, inauthInfo); err == nil {
|
||||
globals.SugarLogger.Debug("进入AddAuthBind=============输出一下user.GetID()", user.GetID())
|
||||
inauthInfo.AuthBindInfo.UserID = user.GetID()
|
||||
outauthInfo = createAuthInfo(user, inauthInfo.AuthBindInfo)
|
||||
}
|
||||
globals.SugarLogger.Debug("=============输出一下outauthInfo", outauthInfo)
|
||||
return outauthInfo, err
|
||||
}
|
||||
|
||||
|
||||
@@ -35,19 +35,16 @@ func (a *QRCodeAuther) VerifySecret(dummy, code string) (*auth2.AuthBindEx, erro
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debug("tmp_userID====,userInfo=======", tmp_userID, userInfo)
|
||||
globals.SugarLogger.Debugf("dingding qrcode VerifySecret code:%s, userQRInfo:%s", code, utils.Format4Output(userQRInfo, false))
|
||||
authBindEx, err := a.UnionFindAuthBind(AuthTypeQRCode, api.DingDingQRCodeAPI.GetAppID(), []string{AuthTypeStaff, AuthTypeQRCode}, userQRInfo.OpenID, userQRInfo.UnionID, userQRInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
authBindEx.UserHint = &auth2.UserBasic{
|
||||
//Name: userQRInfo.Nickname,
|
||||
UserID2: tmp_userID.UserID,
|
||||
Mobile: utils.Interface2String(userInfo["mobile"]),
|
||||
Email: utils.Interface2String(userInfo["email"]),
|
||||
Name: utils.Interface2String(userInfo["name"]),
|
||||
}
|
||||
globals.SugarLogger.Debug("authBindEx.UserHint===============", authBindEx.UserHint)
|
||||
return authBindEx, err
|
||||
}
|
||||
|
||||
@@ -275,6 +275,10 @@ func (c *Auth2Controller) DingDingOAuth2() {
|
||||
Code: model.ErrCodeSuccess,
|
||||
Data: string(utils.MustMarshal(authInfo)),
|
||||
}
|
||||
//增加钉钉扫码 auth_bind 绑定
|
||||
if err := auth2.AddAuthBind(&authInfo.UserBasic, authInfo); err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
} else {
|
||||
callResult = &CallResult{
|
||||
Code: model.ErrCodeGeneralFailed,
|
||||
|
||||
Reference in New Issue
Block a user