认证支持同一类型多绑定

This commit is contained in:
gazebo
2020-02-13 13:45:44 +08:00
parent 67d4e461e2
commit d3cf404a41
11 changed files with 39 additions and 27 deletions

View File

@@ -82,7 +82,7 @@ type IAuther interface {
// 负责验证secret并找到相应的用户返回password,email,mobile类型的不负责用户查找如果找不到用户UserID为空
VerifySecret(authID, authSecret string) (authBindEx *AuthBindEx, err error)
AddAuthBind(authBindEx *AuthBindEx, userName string) (err error)
UnbindAuth(userID, authType, userName string) (err error)
UnbindAuth(userID, authType, authTypeID, userName string) (err error)
Logout(authInfo *AuthInfo) (err error)
GetUserType() (userType int8)
}
@@ -314,7 +314,7 @@ func AddAuthBind(user IUser, newAuthInfo *AuthInfo) (err error) {
} else {
if handler := authers[newAuthInfo.AuthBindInfo.Type]; handler != nil {
newAuthInfo.AuthBindInfo.UserID = user.GetID()
handler.UnbindAuth(user.GetID(), newAuthInfo.GetAuthType(), user.GetName())
handler.UnbindAuth(user.GetID(), newAuthInfo.GetAuthType(), newAuthInfo.GetAuthTypeID(), user.GetName())
err = handler.AddAuthBind(newAuthInfo.AuthBindInfo, user.GetName())
} else {
err = ErrIllegalAuthType
@@ -323,10 +323,10 @@ func AddAuthBind(user IUser, newAuthInfo *AuthInfo) (err error) {
return err
}
func UnbindAuth(userID, authType, userName string) (err error) {
globals.SugarLogger.Debugf("UnbindAuth userID:%s, authType:%s, userName:%s", userID, authType, userName)
func UnbindAuth(userID, authType, authTypeID, userName string) (err error) {
globals.SugarLogger.Debugf("UnbindAuth userID:%s, authType:%s, authTypeID:%s, userName:%s", userID, authType, authTypeID, userName)
if handler := authers[authType]; handler != nil {
err = handler.UnbindAuth(userID, authType, userName)
err = handler.UnbindAuth(userID, authType, authTypeID, userName)
} else {
err = ErrIllegalAuthType
}