up
This commit is contained in:
1 parent
c1da3c89ad
commit
8a0ebe803a
7 files changed
+25
-17
No files matched your search
@@ -4,7 +4,6 @@ import (
|
||||
"isp-system-service/entity"
|
||||
"isp-system-service/model"
|
||||
|
||||
"github.com/integration-system/isp-lib/database"
|
||||
_ "github.com/integration-system/isp-lib/structure"
|
||||
"github.com/integration-system/isp-lib/utils"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -146,7 +145,7 @@ func DeleteApplications(list []int32) (DeleteResponse, error) {
|
||||
return DeleteResponse{}, status.Errorf(codes.InvalidArgument, "At least one id are required")
|
||||
}
|
||||
var count = 0
|
||||
err := database.RunInTransaction(func(appRep model.AppRepository, tokenRep model.TokenRepository) error {
|
||||
err := model.DbClient.RunInTransaction(func(appRep model.AppRepository, tokenRep model.TokenRepository) error {
|
||||
for _, appId := range list {
|
||||
_, err := revokeTokensForApp(Identity{appId}, &tokenRep)
|
||||
if err != nil {
|
||||
|
||||
+5
-7
@@ -1,6 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"isp-system-service/invoker"
|
||||
"time"
|
||||
|
||||
"isp-system-service/conf"
|
||||
@@ -10,7 +11,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/go-redis/redis"
|
||||
"github.com/integration-system/isp-lib/config"
|
||||
"github.com/integration-system/isp-lib/redis"
|
||||
rd "github.com/integration-system/isp-lib/redis"
|
||||
"github.com/integration-system/isp-lib/token-gen"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -71,7 +72,6 @@ func CreateToken(req CreateTokenRequest) (*AppWithToken, error) {
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
c := rd.GetClient()
|
||||
err = SetIdentityMapForToken(token, m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -79,7 +79,7 @@ func CreateToken(req CreateTokenRequest) (*AppWithToken, error) {
|
||||
|
||||
token, err = model.TokenRep.SaveToken(token)
|
||||
if err != nil {
|
||||
c.Del(token.Token)
|
||||
invoker.RedisClient.Del(token.Token)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -146,9 +146,8 @@ func GetTokensByAppId(identity Identity) ([]entity.Token, error) {
|
||||
}
|
||||
|
||||
func SetIdentityMapForTokenV2(token string, expireTime int64, idMap map[string]interface{}) error {
|
||||
c := rd.GetClient()
|
||||
cfg := config.Get().(*conf.Configuration)
|
||||
_, e := c.UseDbTx(rd.ApplicationTokenDb, func(p redis.Pipeliner) error {
|
||||
_, e := invoker.RedisClient.UseDbTx(rd.ApplicationTokenDb, func(p redis.Pipeliner) error {
|
||||
t := fmt.Sprintf("%s|%s", token, cfg.InstanceUuid)
|
||||
stat := p.HMSet(t, idMap)
|
||||
err := stat.Err()
|
||||
@@ -229,8 +228,7 @@ func revokeTokens(tokens []string, tokenRep *model.TokenRepository) (*DeleteResp
|
||||
if len(tokens) == 0 {
|
||||
return &DeleteResponse{0}, nil
|
||||
}
|
||||
c := rd.GetClient()
|
||||
_, e := c.UseDbTx(rd.ApplicationTokenDb, func(p redis.Pipeliner) error {
|
||||
_, e := invoker.RedisClient.UseDbTx(rd.ApplicationTokenDb, func(p redis.Pipeliner) error {
|
||||
deleted, err := tokenRep.DeleteTokens(tokens)
|
||||
count = deleted
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user