w3b3d3v / web3-bootcamp-platform

web3-bootcamp-platform.vercel.app
MIT License
52 stars 24 forks source link

Fix user storage to avoid saving empty data #252

Closed nomadbitcoin closed 2 months ago

nomadbitcoin commented 2 months ago

Brief Information

The type of this pull request is:

What does this PR do?

This commit addresses a critical issue where users were being stored in Firestore without their full names when connecting via Google or GitHub. The main changes include:

  1. In context/AuthContext.js:

    • Implemented separate loginGithub function to handle GitHub authentication
    • Added handleGithubLogin to manage the GitHub login process, including user creation and update
    • Ensured user data is correctly retrieved and stored after authentication
  2. In lib/user.js:

    • Refactored createUserinFirestore to check for existing users before creation
    • Improved GitHub URL retrieval from user credentials
    • Updated user properties to use optional chaining for safer access

These changes resolve the issue of missing user names in Firestore, improve error handling, and ensure a more robust authentication flow across different providers (email, Google, and GitHub).

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
web3-bootcamp-platform ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 9:27pm