Procházet zdrojové kódy

bug: fix RefreshFuncInfo

张延森 před 3 roky
rodič
revize
cd98fb6c7a
3 změnil soubory, kde provedl 28 přidání a 18 odebrání
  1. 8
    1
      authorization.go
  2. 20
    0
      config/authorizer.go
  3. 0
    17
      config/config.go

+ 8
- 1
authorization.go Zobrazit soubor

@@ -67,7 +67,14 @@ func RefreshAuthorizerInfo(authCode string, authorizer config.AuthorizerConfig)
67 67
 	appID := authInfo.AuthorizerAppID
68 68
 	expire := utils.GetExpireTime(authInfo.ExpiresIn)
69 69
 
70
-	authorizer.RefreshFuncInfo(appID, authInfo.FuncInfo)
70
+	funcLst := make([]int, 0)
71
+	if nil != authInfo.FuncInfo && len(authInfo.FuncInfo) > 0 {
72
+		for _, info := range authInfo.FuncInfo {
73
+			funcLst = append(funcLst, info.FuncscopeCategory.ID)
74
+		}
75
+	}
76
+
77
+	authorizer.RefreshFuncInfo(appID, funcLst)
71 78
 	if err := authorizer.RefreshToken(appID, authInfo.AuthorizerAccessToken, authInfo.AuthorizerRefreshToken, expire); err != nil {
72 79
 		return err
73 80
 	}

+ 20
- 0
config/authorizer.go Zobrazit soubor

@@ -0,0 +1,20 @@
1
+package config
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+// AuthorizerConfig 公众号或小程序配置
8
+type AuthorizerConfig interface {
9
+	// GetToken 获取 Token
10
+	GetAccessToken(appID string) string
11
+
12
+	// GetRefreshToken 获取 RefreshToken
13
+	GetRefreshToken(appID string) string
14
+
15
+	// RefreshToken 刷新 Token
16
+	RefreshToken(appID, token, refreshToken string, expire time.Time) error
17
+
18
+	// RefreshFuncInfo 刷新权限集列表
19
+	RefreshFuncInfo(appID string, lst []int)
20
+}

+ 0
- 17
config/config.go Zobrazit soubor

@@ -14,8 +14,6 @@ package config
14 14
 
15 15
 import (
16 16
 	"time"
17
-
18
-	"gitee.com/yansen_zh/wxcomponent/api/authorization"
19 17
 )
20 18
 
21 19
 type Config interface {
@@ -48,18 +46,3 @@ type Config interface {
48 46
 }
49 47
 
50 48
 var conf Config
51
-
52
-// AuthorizerConfig 公众号或小程序配置
53
-type AuthorizerConfig interface {
54
-	// GetToken 获取 Token
55
-	GetAccessToken(appID string) string
56
-
57
-	// GetRefreshToken 获取 RefreshToken
58
-	GetRefreshToken(appID string) string
59
-
60
-	// RefreshToken 刷新 Token
61
-	RefreshToken(appID, token, refreshToken string, expire time.Time) error
62
-
63
-	// RefreshFuncInfo 刷新权限集列表
64
-	RefreshFuncInfo(appID string, lst []authorization.FuncInfo)
65
-}