!token改为7部分
This commit is contained in:
@@ -157,7 +157,7 @@ func getFixedTokenName(token string) *AuthInfo {
|
||||
}
|
||||
|
||||
func createAuthInfo(user IUser, authBindInfo *AuthBindEx) (authInfo *AuthInfo) {
|
||||
token, tokenType := createToken(user)
|
||||
token, tokenType := createToken(user, authBindInfo)
|
||||
expireDuration := DefTokenDuration
|
||||
authInfo = &AuthInfo{
|
||||
AuthBindInfo: authBindInfo,
|
||||
@@ -378,9 +378,9 @@ func ClearUserToken(userID string) {
|
||||
|
||||
/////////////
|
||||
|
||||
func createToken(user IUser) (token string, tokenType int) {
|
||||
func createToken(user IUser, authBindInfo *AuthBindEx) (token string, tokenType int) {
|
||||
userID := TokenUserEmpty
|
||||
userName := TokenUserEmpty
|
||||
userName := authBindInfo.AuthID
|
||||
tokenType = TokenTypeOnlyAuth
|
||||
if user != nil {
|
||||
userID = user.GetID()
|
||||
@@ -392,8 +392,9 @@ func createToken(user IUser) (token string, tokenType int) {
|
||||
TokenVer,
|
||||
userID,
|
||||
time.Now().Format("20060102-150405"),
|
||||
userName,
|
||||
authBindInfo.Type,
|
||||
utils.GetUUID(),
|
||||
userName,
|
||||
}, TokenTypeSep), tokenType
|
||||
}
|
||||
|
||||
@@ -404,7 +405,7 @@ func GetTokenType(token string) (tokenType int) {
|
||||
tokenType = TokenTypeNone
|
||||
if token != "" {
|
||||
tokenPartList := strings.Split(token, TokenTypeSep)
|
||||
if (len(tokenPartList) == 1) || (len(tokenPartList) == 6 && tokenPartList[2] != TokenUserEmpty) {
|
||||
if (len(tokenPartList) == 1) || (len(tokenPartList) >= 6 && tokenPartList[2] != TokenUserEmpty) {
|
||||
tokenType = TokenTypeNormal
|
||||
} else {
|
||||
tokenType = TokenTypeOnlyAuth
|
||||
|
||||
Reference in New Issue
Block a user