BA
Better Auth•2w ago
Emil

additional fields not included in session

The role is included in the session object, but not the onboardingDone. The fieldName is the same as that in the database
No description
Solution:
If you're using an ORM, try removing the fieldName prop from the additional fields
Jump to solution
22 Replies
Ping
Ping•2w ago
Could it be that you're seeing a cached session that may not have your updated onboardingDone?
Emil
EmilOP•2w ago
Thought so too. I tried deleting the session, but still don't see the field
Ping
Ping•2w ago
When you check your DB, do you see that field populated?
Emil
EmilOP•2w ago
yes Also tried deleting the app and reinstalling which should remove all data Is there any additional configurations that should be done in addition to adding the field to additionalFields?
Ping
Ping•2w ago
No I don't believe so. Are you verifying this by just calling getSession?
Emil
EmilOP•2w ago
I'm calling useSession can try getSession getting same result with getSession
Ping
Ping•2w ago
This is werid. 🤔 Do you think you can send the whole auth config? Maybe I can spot something
Solution
Sakshamarora
Sakshamarora•2w ago
If you're using an ORM, try removing the fieldName prop from the additional fields
Sakshamarora
Sakshamarora•2w ago
Faced a similar issue some while back and the culprit was fieldName being passed manually
Emil
EmilOP•2w ago
Thanks! that solved it 🙂 Thanks for all the help guys!
Sakshamarora
Sakshamarora•2w ago
great to hear
Ping
Ping•2w ago
Huh, interesting.
Emil
EmilOP•2w ago
yep. using the drizzle adapter so it seems like it wants to map the fields to the name itself makes sense since it already knows the field names
Sakshamarora
Sakshamarora•2w ago
it doesn’t work even with an identical fieldName that's there in drizzle schema, which makes the behaviour a bit unclear
Ping
Ping•2w ago
fieldName would usually only be used if the DB field name doesn't match the name of the key of that object (onboardingDone) Is this the same idea that you guys have?
Emil
EmilOP•2w ago
yes
Ping
Ping•2w ago
Hmm okay, this is very odd. So I assume you renamed the onboardingDone key to onboarding_done?
Emil
EmilOP•2w ago
yes. using automatic snake case conversion in drizzle. so made sense to declare the fieldName in the auth instance
Ping
Ping•2w ago
@bekacru This might be a bug, I'm not too sure. But previously @Emil set a fieldName to onboarding_done but this didn't work. After removing fieldName and just setting the key to onboarding_done everything works. 🤔
bekacru
bekacru•2w ago
It’s not. The drizzle adapter works at the drizzle level. Meaning it only cares about what key is the field in your drizzle instance. So when you pass fieldName your changing the key name the adapter is looking for.
Ping
Ping•2w ago
Hmm okay. So this is just a Drizzle related issue then.
bekacru
bekacru•2w ago
It’s not an issue

Did you find this page helpful?