No Google Email in Database of User
Hi! I am using the Open Saas Template and implemented Google Authentication for Sign Up and Login, I realised looking into Primsa Database, the table User, it successfully register the user but the email field is null. I ensured I have already requested those /auth/userinfo.email is enabled in Google's side. Was wondering if this is normal behaviour or what do I need to do to get the email showing up inside the database? Thanks!
2 Replies
Hi @Namkatz. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
This issue is related to how Wasp handles Google authentication and user data storage. Based on the knowledge sources provided, I can offer some insights and potential solutions.
The behavior you're experiencing is likely due to the default configuration of Wasp's social authentication system. By default, Wasp doesn't store information received from social login providers (like Google) in the User entity. It only stores the user's ID specific to the provider.
To store additional information like the email, you need to override the default behavior. There are two mechanisms for this:
1.
userSignupFields
2. configFn
To fix your issue and store the email in the database, you should update your Google auth configuration in the main.wasp
file. Here's what you need to do:
1. Ensure you're requesting the correct scopes:
2. Define userSignupFields
to store the email:
3. Update your main.wasp
file to use these functions:
These changes should allow you to store the email in your User entity.
For more detailed information, you can refer to the following resources:
- Google Auth API Reference
- Google Auth Overrides
If you're using an older version of the OpenSaaS template, you might need to update your code to match the latest implementation. A recent support thread on Discord highlighted this issue, where updating the getGoogleUserFields
function resolved a similar problem Discord support thread.
Remember to restart your Wasp server after making these changes for them to take effect.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Namkatz, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Ah I missed the override part, thank you!