Skip to content

Commit 0e0c797

Browse files
committed
fix:fix infinite loop back.
Signed-off-by: leozhang2018 <leozhang2018@gmail.com>
1 parent 16c4f08 commit 0e0c797

3 files changed

Lines changed: 16 additions & 30 deletions

File tree

src/UserAccessControl.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ async function refreshToken(): Promise<boolean> {
124124
console.error('Auth config not found for token refresh');
125125
return false;
126126
}
127-
128127
// 验证配置是否有效
129128
const isValidConfig = await validateConfig();
130129
if (!isValidConfig) {
@@ -134,7 +133,6 @@ async function refreshToken(): Promise<boolean> {
134133

135134
// 获取飞书授权码
136135
const authResult = await sdk.utils.getAuthCode();
137-
138136
// 使用授权码获取新的访问令牌
139137
const success = await getToken(authResult.code);
140138

src/api/AdminRequest.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,15 @@ const isGlobalConfigAPI = (url: string): boolean => {
4848
return url.includes('/api/plugin/lark/auth/config');
4949
};
5050

51-
// 判断是否需要插件认证的 API(排除获取 Token 的 API)
51+
// 判断是否需要插件认证的 API(排除获取 Token 的 API 和测试连接 API,避免循环调用
5252
const needsPluginAuth = (url: string): boolean => {
53-
// 全局配置 API 不需要插件认证
54-
if (url.includes('/api/plugin/lark/auth/config')) {
55-
return false;
56-
}
57-
// 获取用户密钥 API 不需要插件认证(这是获取 Token 的 API)
58-
if (url.includes('/api/plugin/lark/user/key')) {
59-
return false;
60-
}
61-
// 测试连接 API 不需要插件认证
62-
if (url.includes('/api/plugin/lark/test')) {
63-
return false;
64-
}
65-
return true;
53+
const excludedUrls = [
54+
'/api/plugin/lark/auth/config', // 全局配置 API
55+
'/api/plugin/plugin/lark/login', // 获取用户密钥/登录 API
56+
'/api/plugin/v1/policy/permission', // 测试连接 API
57+
];
58+
59+
return !excludedUrls.some(excluded => url.includes(excluded));
6660
};
6761

6862
// 请求拦截器

src/api/UserRequest.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,15 @@ const isGlobalConfigAPI = (url: string): boolean => {
4848
return url.includes('/api/plugin/lark/auth/config');
4949
};
5050

51-
// 判断是否需要插件认证的 API(排除获取 Token 的 API)
51+
// 判断是否需要插件认证的 API(排除获取 Token 的 API 和测试连接 API,避免循环调用
5252
const needsPluginAuth = (url: string): boolean => {
53-
// 全局配置 API 不需要插件认证
54-
if (url.includes('/api/plugin/lark/auth/config')) {
55-
return false;
56-
}
57-
// 获取用户密钥 API 不需要插件认证(这是获取 Token 的 API)
58-
if (url.includes('/api/plugin/lark/user/key')) {
59-
return false;
60-
}
61-
// 测试连接 API 不需要插件认证
62-
if (url.includes('/api/plugin/lark/test')) {
63-
return false;
64-
}
65-
return true;
53+
const excludedUrls = [
54+
'/api/plugin/lark/auth/config', // 全局配置 API
55+
'/api/plugin/plugin/lark/login', // 获取用户密钥/登录 API
56+
'/api/plugin/v1/policy/permission', // 测试连接 API
57+
];
58+
59+
return !excludedUrls.some(excluded => url.includes(excluded));
6660
};
6761

6862
// 请求拦截器

0 commit comments

Comments
 (0)