Skip to content

Commit d4f229f

Browse files
committed
fix: solve merge error.
1 parent 2c99180 commit d4f229f

4 files changed

Lines changed: 23 additions & 78 deletions

File tree

.github/workflows/remove-unused-labels copy.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/openimsdk/chat
22

3-
go 1.21
3+
go 1.21.2
4+
5+
toolchain go1.23.2
46

57
require (
68
github.com/gin-gonic/gin v1.9.1
@@ -11,7 +13,7 @@ require (
1113
github.com/pkg/errors v0.9.1 // indirect
1214
google.golang.org/grpc v1.62.1
1315
google.golang.org/protobuf v1.33.0
14-
gopkg.in/yaml.v3 v3.0.1
16+
gopkg.in/yaml.v3 v3.0.1 // indirect
1517
gorm.io/gorm v1.25.8
1618
)
1719

pkg/common/db/database/admin.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ package database
1616

1717
import (
1818
"context"
19-
"go.mongodb.org/mongo-driver/bson/primitive"
2019
"time"
2120

21+
"go.mongodb.org/mongo-driver/bson/primitive"
22+
2223
"github.com/openimsdk/chat/pkg/common/db/cache"
24+
"github.com/openimsdk/chat/pkg/common/tokenverify"
2325
"github.com/openimsdk/tools/db/mongoutil"
2426
"github.com/openimsdk/tools/db/pagination"
2527
"github.com/openimsdk/tools/db/tx"
@@ -138,7 +140,7 @@ func NewAdminDatabase(cli *mongoutil.Client, rdb redis.UniversalClient, token *t
138140
applet: applet,
139141
clientConfig: clientConfig,
140142
application: application,
141-
cache: cache.NewTokenInterface(rdb),
143+
cache: cache.NewTokenInterface(rdb, token),
142144
}, nil
143145
}
144146

pkg/common/tokenverify/token_verify.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,21 @@ func (t *Token) GetToken(token string) (string, int32, error) {
109109
return userID, userType, nil
110110
}
111111

112+
func (t *Token) GetExpire(token string) time.Time {
113+
val, err := jwt.ParseWithClaims(token, &claims{}, t.secret())
114+
if err != nil {
115+
return time.Time{}
116+
}
117+
c, ok := val.Claims.(*claims)
118+
if !ok {
119+
return time.Time{}
120+
}
121+
if c.ExpiresAt == nil {
122+
return time.Time{}
123+
}
124+
return c.ExpiresAt.Time
125+
}
126+
112127
//func (t *Token) GetAdminTokenCache(token string) (string, error) {
113128
// userID, userType, err := getToken(token)
114129
// if err != nil {

0 commit comments

Comments
 (0)