wasp
wasp copied to clipboard
Improve our API for getting `providerData` for our auth providers
When users get the new AuthUser
object, it contains a list of available auth identities. Each of those auth identities contains some extra fields in providerData
(which fields are available depends on the auth provider).
There should a straightforward and type safe way to get the providerData
for our users.
What we did ourselves
In the todoApp example app, we did the following:
export function getProviderData(user?: AuthUser) {
if (!user) {
return null
}
const emailIdentity = findUserIdentity(user, 'email')
return emailIdentity && 'isEmailVerified' in emailIdentity.providerData
? emailIdentity.providerData
: null
}
Good solution
I believe we can introduce a new API that would be called e.g. getProviderData<ProviderName>
which can return the proper type based on the value of the generic param ProviderName
. Or something similar, but ideally, users can use getProviderData
and get a typed object.
Related issue: https://github.com/wasp-lang/wasp/issues/1800 .