Question about the Session recipe...
d
Question about the Session recipe...
Hi again! This time I have a question about the Session Recipe...
I see that there is a createNewSession function in the API: → https://supertokens.com/docs/session/common-customizations/sessions/new-session
This function call takes a response object. Firebase has authentication handlers. One of which, for example, is "onUserCreated". There is a callback to this function when a new User is created. In Firebase, it is the natural place to handle anything that has to be done when a new User is created. However, there is no response object available, because it is not done as a request/response. I think this can still be used to create user roles and such, which is great: → https://supertokens.com/docs/session/user-roles/creating-role I am just wondering if there is some way to also create a new Session from this handler even without a response object. My thinking is that could potentially allow me to avoid having to make an extra call Any thoughts?
r
Hey! So the
createNewSession
function should be called in an API that is called from your frontend. So the best way to handle this would be to make firebase send a request to your frontend app (web server) with the JWT token for the user, and then your frontend queries the backend with the token. The backend can then verify the token and call the createNewSession function. The reason why it requires a response object is cause the function attaches the tokens as cookies.
d
Ok, understood. Thanks!
3 Views