From 93a3b60acf76f70b9c6473838d973fb6cd76bebd Mon Sep 17 00:00:00 2001 From: Camille Reaves Date: Sat, 23 Sep 2023 18:54:50 -0400 Subject: [PATCH] Update sprout.js --- public/sprout.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/public/sprout.js b/public/sprout.js index 0e77ba4..b7d79eb 100644 --- a/public/sprout.js +++ b/public/sprout.js @@ -179,9 +179,14 @@ function generateUsername(userNameExists, firstName, lastName, month, day, year) async function testUserEmail(testEmail){ testEmail = testEmail.toString(); - const q = query(newUserRequest, where('UserEmail', '==', testEmail)); - const checkEmail = (await getDocs(q)).docs.length; - if (checkEmail > 0){ + const q = query((db, 'new_user_requests'), where('UserEmail', '==', testEmail)); + const checkEmail = await getDocs(q); + let count = 0; + checkEmail.forEach((doc) => { + count += 1; + }); + console.log("checkEmail = " + count); + if (count > 0){ return true; } else{ return false; @@ -191,9 +196,13 @@ async function testUserEmail(testEmail){ async function testUserName(testUsername){ testUsername = testUsername.toString(); const docRef = doc(db, 'new_user_requests', testUsername); - const docCheck = await getDoc(docRef); - console.log("docCheck = "+ docCheck); - if (docCheck.exists){ + const docCheck = await getDocs(docRef); + let count = 0; + docCheck.forEach((doc) => { + count += 1; + }); + console.log("docCheck = "+ count); + if (count > 0){ return true; } else{ return false;