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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user