Merge branch 'main' into main
This commit is contained in:
commit
1f4dc6263c
53
.idea/workspace.xml
generated
53
.idea/workspace.xml
generated
@ -4,16 +4,10 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="987ac7e2-ceaa-49a2-b5c9-aed65a7c598d" name="更改" comment="fin onedrive official token">
|
||||
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/cf-worker-api.iml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
||||
<list default="true" id="987ac7e2-ceaa-49a2-b5c9-aed65a7c598d" name="更改" comment="deal merge issue">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/public/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/public/index.html" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/public/static/style-all.css" beforeDir="false" afterPath="$PROJECT_DIR$/public/static/style-all.css" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wrangler.jsonc.example" beforeDir="false" afterPath="$PROJECT_DIR$/wrangler.jsonc" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -23,6 +17,9 @@
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProblemsViewState">
|
||||
<option name="selectedTabId" value="CurrentFile" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"associatedIndex": 4
|
||||
}</component>
|
||||
@ -69,8 +66,41 @@
|
||||
<updated>1749696640494</updated>
|
||||
<workItem from="1749696641557" duration="119000" />
|
||||
<workItem from="1749696773818" duration="18000" />
|
||||
<workItem from="1749696801474" duration="7490000" />
|
||||
<workItem from="1749696801474" duration="15061000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="fin onedrive official token">
|
||||
<option name="closed" value="true" />
|
||||
<created>1749704488857</created>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1749704488857</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00002" summary="add readme">
|
||||
<option name="closed" value="true" />
|
||||
<created>1749705341327</created>
|
||||
<option name="number" value="00002" />
|
||||
<option name="presentableId" value="LOCAL-00002" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1749705341327</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00003" summary="add onedrive area: cn us de">
|
||||
<option name="closed" value="true" />
|
||||
<created>1749712084921</created>
|
||||
<option name="number" value="00003" />
|
||||
<option name="presentableId" value="LOCAL-00003" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1749712084921</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00004" summary="deal merge issue">
|
||||
<option name="closed" value="true" />
|
||||
<created>1749712420228</created>
|
||||
<option name="number" value="00004" />
|
||||
<option name="presentableId" value="LOCAL-00004" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1749712420228</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="5" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@ -78,6 +108,9 @@
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="fin onedrive official token" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="fin onedrive official token" />
|
||||
<MESSAGE value="add readme" />
|
||||
<MESSAGE value="add onedrive area: cn us de" />
|
||||
<MESSAGE value="deal merge issue" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="deal merge issue" />
|
||||
</component>
|
||||
</project>
|
@ -233,7 +233,7 @@
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: '授权失败',
|
||||
text: message_err,
|
||||
html: message_err,
|
||||
showConfirmButton: true,
|
||||
});
|
||||
}
|
||||
|
65
src/index.ts
65
src/index.ts
@ -60,20 +60,33 @@ app.get('/onedrive/requests', async (c) => {
|
||||
})
|
||||
// 令牌申请 ##############################################################################
|
||||
app.get('/onedrive/callback', async (c) => {
|
||||
const login_data = <string>c.req.query('code');
|
||||
const client_uid: string = <string>local.getCookie(c, 'client_uid')
|
||||
const client_key: string = <string>local.getCookie(c, 'client_key')
|
||||
const driver_txt: string = <string>local.getCookie(c, 'apps_types')
|
||||
const client_url: string = driver_map[driver_txt][1];
|
||||
console.log(login_data);
|
||||
// 请求参数 ==========================================================================
|
||||
const params_all = {
|
||||
client_id: client_uid,
|
||||
client_secret: client_key,
|
||||
redirect_uri: 'https://' + c.env.MAIN_URLS + '/onedrive/callback',
|
||||
code: login_data,
|
||||
grant_type: 'authorization_code'
|
||||
};
|
||||
let login_data, client_uid, client_key, driver_txt, client_url, params_all;
|
||||
try { // 请求参数 ====================================================================
|
||||
login_data = <string>c.req.query('code');
|
||||
client_uid = <string>local.getCookie(c, 'client_uid')
|
||||
client_key = <string>local.getCookie(c, 'client_key')
|
||||
driver_txt = <string>local.getCookie(c, 'apps_types')
|
||||
client_url = driver_map[driver_txt][1];
|
||||
params_all = {
|
||||
client_id: client_uid,
|
||||
client_secret: client_key,
|
||||
redirect_uri: 'https://' + c.env.MAIN_URLS + '/onedrive/callback',
|
||||
code: login_data,
|
||||
grant_type: 'authorization_code'
|
||||
};
|
||||
} catch (error) {
|
||||
return c.redirect(
|
||||
`/?message_err=${"授权失败,请检查: <br>" +
|
||||
"1、应用ID和应用机密是否正确<br>" +
|
||||
"2、登录账号是否具有应用权限<br>" +
|
||||
"3、回调地址是否包括上面地址<br>" +
|
||||
"4、登录可能过期,请重新登录<br>" +
|
||||
"错误信息: <br> " + error}`
|
||||
+ `&client_uid=NULL`
|
||||
+ `&client_key=`);
|
||||
}
|
||||
// console.log(login_data);
|
||||
|
||||
// 执行请求 ===========================================================================
|
||||
try {
|
||||
const paramsString = new URLSearchParams(params_all).toString();
|
||||
@ -84,9 +97,19 @@ app.get('/onedrive/callback', async (c) => {
|
||||
},
|
||||
body: paramsString,
|
||||
});
|
||||
console.log(response);
|
||||
// console.log(response);
|
||||
local.deleteCookie(c, 'client_uid');
|
||||
local.deleteCookie(c, 'client_key');
|
||||
local.deleteCookie(c, 'apps_types');
|
||||
if (!response.ok)
|
||||
return c.json({text: response.text()}, 403);
|
||||
return c.redirect(
|
||||
`/?message_err=${"授权失败,请检查: <br>" +
|
||||
"1、应用ID和应用机密是否正确<br>" +
|
||||
"2、登录账号是否具有应用权限<br>" +
|
||||
"3、回调地址是否包括上面地址<br>" +
|
||||
"错误信息: <br>" + response.text()}`
|
||||
+ `&client_uid=${client_uid}`
|
||||
+ `&client_key=${client_key}`);
|
||||
const json: Record<string, any> = await response.json();
|
||||
if (json.token_type === 'Bearer') {
|
||||
return c.redirect(
|
||||
@ -96,8 +119,14 @@ app.get('/onedrive/callback', async (c) => {
|
||||
+ `&client_key=${client_key}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return c.json({text: error}, 500);
|
||||
return c.redirect(
|
||||
`/?message_err=${"授权失败,请检查: <br>" +
|
||||
"1、应用ID和应用机密是否正确<br>" +
|
||||
"2、登录账号是否具有应用权限<br>" +
|
||||
"3、回调地址是否包括上面地址<br>" +
|
||||
"错误信息: <br>" + error}`
|
||||
+ `&client_uid=${client_uid}`
|
||||
+ `&client_key=${client_key}`);
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user