File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,24 @@ export function App() {
19
19
20
20
useEffect ( ( ) => {
21
21
if ( code ) {
22
- console . log ( "test1" )
23
22
const asyncSaveAuth = async ( ) => {
24
23
const response = await fetch ( `/access_token/${ code } ` )
24
+ const accessToken = await response . text ( )
25
+ localStorage . setItem ( 'gitHub_access_token' , accessToken ) ;
25
26
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 ( ) ;
28
40
}
29
41
30
42
asyncSaveAuth ( )
You can’t perform that action at this time.
0 commit comments