1
+ < html lang ="en ">
2
+ < head >
3
+ < meta name ="google-signin-scope "
4
+ content ="profile email https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/cloud-platform ">
5
+ < meta name ="google-signin-client_id "
6
+ content ="175047346381-6rndk8rtpahjmiojj7km41ls4gojldar.apps.googleusercontent.com ">
7
+ < script src ="https://apis.google.com/js/platform.js " async defer > </ script >
8
+
9
+ < style >
10
+ html , body {
11
+ font-family : sans-serif;
12
+ height : 100% ;
13
+ margin : 0 ;
14
+ display : flex;
15
+ flex-direction : column;
16
+ align-items : center;
17
+ justify-content : center;
18
+ }
19
+ </ style >
20
+
21
+ </ head >
22
+
23
+ < body >
24
+
25
+ < h3 > FireCMS CLI</ h3 >
26
+ < div class ="g-signin2 " data-onsuccess ="onSignIn "
27
+ data-onfailure ="onFailure ">
28
+ </ div >
29
+ < p > This tab will close automatically after you sign in</ p >
30
+
31
+ < script >
32
+
33
+ function reqListener ( ) {
34
+ window . close ( ) ;
35
+ }
36
+
37
+ function onSignIn ( googleUser ) {
38
+ console . log ( googleUser . getAuthResponse ( ) ) ;
39
+ const access_token = googleUser . getAuthResponse ( ) . access_token ;
40
+ const oReq = new XMLHttpRequest ( ) ;
41
+ oReq . addEventListener ( "load" , reqListener ) ;
42
+ oReq . open ( "POST" , "/result/" + access_token ) ;
43
+ oReq . send ( ) ;
44
+ }
45
+
46
+ function onFailure ( error ) {
47
+ console . log ( error ) ;
48
+ const oReq = new XMLHttpRequest ( ) ;
49
+ // oReq.addEventListener("load", reqListener);
50
+ oReq . open ( "POST" , "/error/" ) ;
51
+ oReq . send ( ) ;
52
+ }
53
+
54
+ function signOut ( ) {
55
+ console . log ( "signOut" ) ;
56
+ var auth2 = gapi . auth2 . getAuthInstance ( ) ;
57
+ auth2 . signOut ( ) . then ( function ( ) {
58
+ console . log ( 'User signed out.' ) ;
59
+ } ) ;
60
+ }
61
+
62
+ // window.addEventListener('beforeunload', function (e) {
63
+ // e.returnValue = '';
64
+ // const oReq = new XMLHttpRequest();
65
+ // oReq.open("POST", "/error/");
66
+ // oReq.send();
67
+ // });
68
+
69
+ </ script >
70
+
71
+ </ body >
72
+ </ html >
0 commit comments