Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user storage to avoid saving empty data #252

Merged
merged 3 commits into from
Sep 25, 2024

Conversation

nomadbitcoin
Copy link
Contributor

Brief Information

The type of this pull request is:

  • bug fixing
  • new feature
  • others

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).

Copy link

vercel bot commented Sep 25, 2024

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

@nomadbitcoin nomadbitcoin merged commit 8b1a679 into main Sep 25, 2024
4 of 5 checks passed
@nomadbitcoin nomadbitcoin deleted the fix/name-missing-at-login-providers branch September 25, 2024 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant