From b0f01994b7ef819f05811c09afa7f0be03d24fc6 Mon Sep 17 00:00:00 2001 From: WeiViv <100058931+WeiViv@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:52:36 -0600 Subject: [PATCH] fix(auth): change to use the log in email as the email saved in the user profile --- src/utils/firebase/auth.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils/firebase/auth.ts b/src/utils/firebase/auth.ts index c7bffcc..552c0fb 100644 --- a/src/utils/firebase/auth.ts +++ b/src/utils/firebase/auth.ts @@ -13,12 +13,18 @@ const loginUser = async ( const result = await signInWithPopup(auth, provider); const user = result.user; + if (!user.email) { + throw new Error('User email is not available.'); + } + const photoURL = user.photoURL ?? ''; const displayName = user.displayName ?? ''; + const email = user.email; // Extract the user's login email if (userType === 'donor') { const donorProfile = await getDonorProfile( user.uid, + email, // Pass the email photoURL, displayName ); @@ -27,6 +33,7 @@ const loginUser = async ( } else { const organizationProfile = await getOrganizationProfile( user.uid, + email, // Pass the email photoURL, displayName );