Hello all, how can I add metadata to my users? For a SaaS app I want to be able to add an orgId as well as role. I thought I had found something for role but can't seem to find it again
So, what does the workflow look like with this? I'm using EmailPassword recepie. The user signsup on the frontend (I also need to be able to invite users from within the app, but that is for later). I then attach the metadata using the userId from the backend. How does the frontend then get the metadata?
ankitmhn
04/07/2022, 10:14 AM
Would the getUserInfo provide the user metadata?
r
rp_st
04/07/2022, 10:22 AM
The backend can retrieve the metadata for the userId using the API from the above spec, and you can send that to the frontend in a couple of ways:
- Create an API on the backend that verifies the user's session -> gets the user id -> queries the core to get the meta data -> send it to the frontend; OR
- Store the metadata in the access token's payload and retrieve that on the frontend without an API call. The downside to this approach is that the access token's side increases to contain whatever you are putting in it, so use this method only if you need to get the metadata often on the frontend.
SuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).