Skip to content

Commit

Permalink
fix: solve merge error.
Browse files Browse the repository at this point in the history
  • Loading branch information
mo3et committed Nov 25, 2024
1 parent 2c99180 commit d4f229f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 78 deletions.
74 changes: 0 additions & 74 deletions .github/workflows/remove-unused-labels copy.yml

This file was deleted.

6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/openimsdk/chat

go 1.21
go 1.21.2

toolchain go1.23.2

require (
github.com/gin-gonic/gin v1.9.1
Expand All @@ -11,7 +13,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0
gopkg.in/yaml.v3 v3.0.1
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/gorm v1.25.8
)

Expand Down
6 changes: 4 additions & 2 deletions pkg/common/db/database/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ package database

import (
"context"
"go.mongodb.org/mongo-driver/bson/primitive"
"time"

"go.mongodb.org/mongo-driver/bson/primitive"

"github.com/openimsdk/chat/pkg/common/db/cache"
"github.com/openimsdk/chat/pkg/common/tokenverify"
"github.com/openimsdk/tools/db/mongoutil"
"github.com/openimsdk/tools/db/pagination"
"github.com/openimsdk/tools/db/tx"
Expand Down Expand Up @@ -138,7 +140,7 @@ func NewAdminDatabase(cli *mongoutil.Client, rdb redis.UniversalClient, token *t
applet: applet,
clientConfig: clientConfig,
application: application,
cache: cache.NewTokenInterface(rdb),
cache: cache.NewTokenInterface(rdb, token),
}, nil
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/common/tokenverify/token_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ func (t *Token) GetToken(token string) (string, int32, error) {
return userID, userType, nil
}

func (t *Token) GetExpire(token string) time.Time {
val, err := jwt.ParseWithClaims(token, &claims{}, t.secret())
if err != nil {
return time.Time{}
}
c, ok := val.Claims.(*claims)
if !ok {
return time.Time{}
}
if c.ExpiresAt == nil {
return time.Time{}
}
return c.ExpiresAt.Time
}

//func (t *Token) GetAdminTokenCache(token string) (string, error) {
// userID, userType, err := getToken(token)
// if err != nil {
Expand Down

0 comments on commit d4f229f

Please sign in to comment.