@@ -9,6 +9,7 @@ import { doc, getDoc, setDoc, updateDoc } from "https://www.gstatic.com/firebase
99
1010// Wait for DOM to load
1111document . addEventListener ( "DOMContentLoaded" , ( ) => {
12+ console . log ( "DOM fully loaded and parsed" ) ;
1213 onAuthStateChanged ( auth , handleAuthStateChanged ) ;
1314
1415 // Set up event listeners
@@ -46,11 +47,13 @@ async function handleLogin(e) {
4647 try {
4748 const userCredential = await signInWithEmailAndPassword ( auth , email , password ) ;
4849 const user = userCredential . user ;
50+ console . log ( "User logged in:" , user ) ;
4951
5052 // Get user status using the modular syntax
5153 const userDoc = await getDoc ( doc ( db , "users" , user . uid ) ) ;
5254 if ( userDoc . exists ( ) ) {
5355 const userData = userDoc . data ( ) ;
56+ console . log ( "User data:" , userData ) ;
5457 if ( userData . status !== "approved" ) {
5558 await signOut ( auth ) ;
5659 if ( errorMsg ) {
@@ -89,6 +92,7 @@ async function handleRegister(e) {
8992 try {
9093 const userCredential = await createUserWithEmailAndPassword ( auth , email , password ) ;
9194 const user = userCredential . user ;
95+ console . log ( "User registered:" , user ) ;
9296
9397 // Store user status in Firestore as "pending"
9498 await setDoc ( doc ( db , "users" , user . uid ) , {
@@ -123,6 +127,7 @@ function handleLogout(e) {
123127
124128 signOut ( auth )
125129 . then ( ( ) => {
130+ console . log ( "User logged out" ) ;
126131 window . location . href = "index.html" ;
127132 } )
128133 . catch ( ( error ) => {
@@ -186,6 +191,7 @@ async function handleApproveUser(e) {
186191 await updateDoc ( doc ( db , "users" , userId ) , {
187192 status : "approved" ,
188193 } ) ;
194+ console . log ( "User approved:" , userId ) ;
189195
190196 // Show success message
191197 const message = document . getElementById ( "message" ) ;
0 commit comments