mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-04 00:55:59 +08:00
remove invalid token
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
commonDB "Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
"time"
|
||||
)
|
||||
@@ -43,6 +44,21 @@ func CreateToken(userID string, platformID int32) (string, int64, error) {
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
//remove Invalid token
|
||||
m, err := commonDB.DB.GetTokenMapByUidPid(userID, constant.PlatformIDToName(platformID))
|
||||
if err != nil && err != redis.ErrNil {
|
||||
return "", 0, err
|
||||
}
|
||||
var deleteTokenKey []string
|
||||
for k, v := range m {
|
||||
if v != constant.NormalToken {
|
||||
deleteTokenKey = append(deleteTokenKey, k)
|
||||
}
|
||||
}
|
||||
err = commonDB.DB.DeleteTokenByUidPid(userID, platformID, deleteTokenKey)
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
err = commonDB.DB.AddTokenFlag(userID, platformID, tokenString, constant.NormalToken)
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
|
||||
Reference in New Issue
Block a user