how do I show the users email on my frontend.
Hi kapa how can i show the users email on my frontend. Also for my opensaas project how can i extend the register field to have more things related to b2b.
7 Replies
Hi @Sven. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To display the user's email on your frontend, you can use the
getEmail
helper function provided by Wasp. This function returns the user's email or null
if the user doesn't have an email auth identity. Here's an example of how you can use it:
You can find more details about this in the Wasp documentation (https://wasp-lang.dev/docs/auth/entities#accessing-the-auth-fields).
As for extending the registration field for your OpenSaaS project, you can customize the SignupForm
component by passing in the additionalFields
prop. This prop can be either a list of extra fields or a render function. Here's an example:
You can find more details about this in the Wasp documentation (https://wasp-lang.dev/docs/auth/overview#signupform-customization).
Remember, for the server to know how to save these extra fields to the database, you need to define the auth.methods.{authMethod}.userSignupFields
field in your main.wasp
file. Here's an example:
You can find more details about this in the Wasp documentation (https://wasp-lang.dev/docs/auth/overview#signup-fields-customization).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Sven, 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?doesnt work, i cant seem to get the username/email on a page. Do i really need to write my own query for that?
If you are using the SaaS template you can check @src/user/AccountPage.tsx
xxxx.tsx:131 Uncaught TypeError: Cannot read properties of undefined (reading 'email')
would this be because it is not loaded yet or something
when adding {!!user.email && (
)}
it still does not work
i imported : import type { User } from 'wasp/entities';
and added : ({ user }: { user: User })
You can trigger Kapa mentioning it again and give him more code context
I just created this
Ill try that
Weird that in accountpahe it works
But when i do it somewhere else it doesnt
Probably some load await