tenant id in access token
# support-questions
I need to store a
information on my user (like, to which organisation he belongs). I am currently doing this via the metadata. Everything is fine there. I am not really happy because I need to make a separate request just to get that info. I need to check that my
really has access to the tenant he's trying to reach. How can I avoid a second request just to get a basic info ?
hey @whatsappx-thomas you can store the tenant id in user metadata, and then you can override the createNewSession function and read the tenant id from the user metadata and put it in the access token payload. From there on, you can read the tenant id from the session's access token payload directly on the frontend and in your apis
Is the metadata available in createNewSession while the account is being created? I'm debugging this now as this info seems to be null until logout/in.
are you adding the metadata in the apis override or in functions override? In the apis override, when you call the original implementation, that internally calls the function override and then the createNewSession before returning. So if you want to do something before createNewSession, you should add that logic in the function override
@rp can you pinpoint me some doc on how to override the createNewSession function ? Can't find it on the SuperTokens doc
There is something I don't understand though: How can I have access to the metadata in the
> How can I have access to the metadata in the createNewSession ? You have the user ID as an input tot he createNewSession function. You can query the user metadata recipe with the userId to get info about the user. You can even query your own db if you like.