adrianhajdin / ai_saas_app

Build a REAL Software-as-a-Service app with AI features and payments & credits system that you might even turn into a side income or business idea using Next.js 14, Clerk, MongoDB, Cloudinary AI, and Stripe.
https://jsmastery.pro
1.07k stars 337 forks source link

fix: change username to email because we receive null on username from clerk #31

Closed billy93 closed 2 months ago

billy93 commented 2 months ago

Hi Adrian,

Based on a question from one of the members on Discord: https://discord.com/channels/710138849350647871/710138850009284681/1265213027045871730,

I tried forking your project and setting it up locally. After logging in, the UI didn't show any errors, but when trying to access the payment page, an error occurred. It turns out that the user wasn't saved to Mongodb because the webhook response from Clerk returned a null username.

Here is an example of the response from Clerk that I received:

{ "data": { "email_addresses": [ { "email_address": "billyfebram@gmail.com" } ], "username": null }, "event_attributes": { "http_request": { "client_ip": "182.253.47.54", "user_agent": "Mozilla/5.0" } }, "object": "event", "type": "user.created" }

Therefore, to prevent the same error from recurring and to ensure that the username is not null, I suggest saving the email as a replacement for the username

vercel[bot] commented 2 months ago

@billy93 is attempting to deploy a commit to the JS Mastery Pro Team on Vercel.

A member of the Team first needs to authorize it.