Skip to content

Commit b23d364

Browse files
feat: 修改比较逻辑和日志
1 parent 12b94c9 commit b23d364

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

utils/syncTokenUtil.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ class syncTokenUtils {
149149
let accessToken = this.getTokenByPath(result, oauthData.token_path);
150150
//更新到对应的env上;
151151
await this.updateProjectToken(accessToken, oauthData, projectData);
152-
this.saveSyncLog(0, '更新token成功', '1', projectId);
153-
yapi.commons.log('更新token成功');
152+
this.saveSyncLog(0, '环境:【' + oauthData.env_name + '】更新新的token【' + accessToken + '】成功', '1', projectId);
153+
yapi.commons.log('环境:【' + oauthData.env_name + '】更新token成功');
154154
} catch (e) {
155-
this.saveSyncLog(-1, '数据格式出错,请检查', '1', projectId);
156-
yapi.commons.log('获取数据失败' + e.message);
155+
this.saveSyncLog(-1, '环境:【' + oauthData.env_name + '】数据格式出错,请检查', '1', projectId);
156+
yapi.commons.log('环境:【' + oauthData.env_name + '】获取数据失败' + e.message);
157157
}
158158
}
159159

@@ -165,7 +165,7 @@ class syncTokenUtils {
165165
*/
166166
async updateProjectToken(accessToken, oauthData, projectData) {
167167
for (let i = 0; i < projectData.env.length; i++) {
168-
if (projectData.env[i]._id == oauthData.env_id) {
168+
if (projectData.env[i]._id == oauthData.env_id || projectData.env[i]._id.toString() == oauthData.env_id.toString()) {
169169
let newItem = {
170170
name: oauthData.token_header,
171171
value: accessToken

0 commit comments

Comments
 (0)