wasp-lang / wasp

The fastest way to develop full-stack web apps with React & Node.js.
https://wasp-lang.dev
MIT License
12.73k stars 1.13k forks source link

Fix the auth helpers to only require fields they need from `AuthIdentity` #2057

Closed infomiho closed 1 week ago

infomiho commented 1 month ago

The auth helpers like getEmail and getUsername didn't work unless you provided the full user object with full AuthIdentity objects in the identities array.

Given that we suggest to users to include only the providerName and providerUserId when manually fetching the user + auth + identities, we should make sure our auth helpers work in that scenario.

This PR:

infomiho commented 1 week ago

Good point! The tricky part with the UserEntityWithAuth name is that it is correct in a sense that it represents a tree of full Prisma entities. The second type is derived from it by making it as minimal as possible to make the function as flexible as possible.

The problem is that the user will see this wacky (albeit correct) name, and we want to do better.

Some alternatives:

I maybe like the first option the best since it's just a Complete vs nothing which gives us the relationship you suggested.