@@ -49,19 +49,17 @@ auth.signInWithPopup(provider)
4949
5050auth . onAuthStateChanged ( async ( user ) => {
5151 if ( user ) {
52- const uid = user . uid ;
53- const snapshot = await db . ref ( "users/" + uid ) . once ( "value" ) ;
54- const userData = snapshot . val ( ) ;
52+ const email = user . email ;
53+ userInfo . innerText = `Signed in as ${ user . displayName } ` ;
54+ signInBtn . style . display = "none" ;
5555
56- if ( userData && userData . currentGameUrl ) {
57- const link = document . createElement ( 'a' ) ;
58- link . href = userData . currentGameUrl ;
59- link . textContent = `Join your match as ${ userData . lichessColor } ` ;
60- link . target = "_blank" ;
61- document . body . appendChild ( link ) ;
56+ if ( email === "[email protected] " ) { 57+ document . getElementById ( "admin-panel" ) . style . display = "block" ;
6258 }
59+
60+ loadLeaderboard ( ) ;
6361 }
64- } ) ;
62+ } ) ;
6563
6664function loadLeaderboard ( ) {
6765 db . ref ( "users" ) . once ( "value" ) . then ( snapshot => {
@@ -88,14 +86,4 @@ function startRound() {
8886 fetch ( "https://your-glitch-app.glitch.me/start-round" , { method : "POST" } )
8987 . then ( res => res . json ( ) )
9088 . then ( data => alert ( `Started new round with ${ data . pairings } games.` ) ) ;
91- }
92-
93- auth . onAuthStateChanged ( async ( user ) => {
94- if ( user ) {
95- const email = user . email ;
96- if ( email === "[email protected] " ) { 97- document . getElementById ( "admin-panel" ) . style . display = "block" ;
98- }
99- loadLeaderboard ( ) ;
100- }
101- } ) ;
89+ }
0 commit comments