Skip to content

Commit 2060e93

Browse files
committedFeb 6, 2025
Update App.tsx
1 parent a810ec8 commit 2060e93

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed
 

‎src/App.tsx

+15-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,24 @@ export function App() {
1919

2020
useEffect(() => {
2121
if (code) {
22-
console.log("test1")
2322
const asyncSaveAuth = async () => {
2423
const response = await fetch(`/access_token/${code}`)
24+
const accessToken = await response.text()
25+
localStorage.setItem('gitHub_access_token', accessToken);
2526

26-
localStorage.setItem('gitHub_access_token', await response.text());
27-
window.location.href = "https://github.com/apps/issue-wrapper/installations/new", "_self"
27+
const installationResponse = await fetch("https://api.github.com/user/installations", {
28+
headers: { Authorization: `token ${accessToken}` }
29+
});
30+
31+
const installations = await installationResponse.json();
32+
33+
if (installations.total_count === 0 || !installations.installations.some((installation: { app_id: string }) => installation.app_id == "1123503")) {
34+
window.location.href = "https://github.com/apps/issue-wrapper/installations/new";
35+
return;
36+
}
37+
38+
window.open("about:blank", "_self");
39+
window.close();
2840
}
2941

3042
asyncSaveAuth()

0 commit comments

Comments
 (0)
Please sign in to comment.