Skip to content

Commit

Permalink
fix(auth): change to use the log in email as the email saved in the u…
Browse files Browse the repository at this point in the history
…ser profile
  • Loading branch information
WeiViv committed Nov 18, 2024
1 parent a19fdb9 commit b0f0199
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/utils/firebase/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand All @@ -27,6 +33,7 @@ const loginUser = async (
} else {
const organizationProfile = await getOrganizationProfile(
user.uid,
email, // Pass the email
photoURL,
displayName
);
Expand Down

0 comments on commit b0f0199

Please sign in to comment.