File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 8282 console . log ( user . email )
8383 console . log ( user . uid )
8484 document . getElementById ( "sign-out" ) . style . display = "block" ;
85+ user . getIdToken ( ) . then ( function ( token ) {
86+ // Add the token to the browser's cookies. The server will then be
87+ // able to verify the token against the API.
88+ // SECURITY NOTE: As cookies can easily be modified, only put the
89+ // token (which is verified server-side) in a cookie; do not add other
90+ // user information.
91+ document . cookie = "token=" + token ;
92+ } ) ;
8593 } else {
8694 console . log ( "No user signed in" )
8795 }
Original file line number Diff line number Diff line change @@ -111,6 +111,14 @@ <h2>Login info:</h2>
111111 ui . reset ( ) ;
112112 document . getElementById ( 'login-info' ) . style . display = 'block' ;
113113 document . getElementById ( 'sign-out' ) . style . display = 'block' ;
114+ user . getIdToken ( ) . then ( function ( token ) {
115+ // Add the token to the browser's cookies. The server will then be
116+ // able to verify the token against the API.
117+ // SECURITY NOTE: As cookies can easily be modified, only put the
118+ // token (which is verified server-side) in a cookie; do not add other
119+ // user information.
120+ document . cookie = "token=" + token ;
121+ } ) ;
114122 } else {
115123 // No user signed in, render sign-in UI.
116124 ui . start ( '#firebaseui-auth-container' , uiConfig ) ;
You can’t perform that action at this time.
0 commit comments