Hi! I am trying to put some data into the user's session. From what I read in the documentation, it ...
m
Hi! I am trying to put some data into the user's session. From what I read in the documentation, it says that I should override the default
createNewSession
implementation. I am trying to do so, but the new function doesn't seem to get called. Here is a code snippet
Copy code
ts
SessionNode.init({
    override: {
        functions: (originalImplementation) => {
            return {
                ...originalImplementation,
                createNewSession: async function (input) {
                    console.log("function is working!"); // <-- this doesn't get logged

                    return originalImplementation.createNewSession(
                        input
                    );
                },
            };
        },
    },
}),
Can you tell me if I am doing something wrong? Thanks in advance
r
Hey!
Which other recipe are you using?
@miraja27
m
I am following the Email Password + Social Login recipe
r
Are you calling the sign in or sign up API? Via the frontend of via postman?
m
I have tested both from the frontend
And both dont seem to trigger the createNewSession method
r
which API have you called from the frontend?
m
I am using the default UI provided from SuperTokens
r
hmm thats odd. Are you sure you have rebuilt your code? Can you add a console log somewhere near when you call supertokens.init to see if that gets printend?
m
Yes I am sure. I have another override in the same config which gets called
r
I see. When you make the login request from the frontend, do you get back session tokens?
m
I have to check. I am currently not on a computer, but once I get back I will check.
r
alright
m
Hi. I checked and I receive session tokens. In fact if I use
mergeIntoAccessTokenPayload
method it extends the session properly. This still doesn't solve my problem though since I need the
createNewSession
override to work.
r
This is very strange. Almost everyone requires to override createNewSession and it always gets called. Maybe there is some silly config issue. Can you show me your entire init code? Including supertokens.init. Are you sure you are not doing supertokens.init on the backend twice? (One without the override which executes first)
m
r
oh btw, you have your API key in the above file, and this channel is public
you can change the API key on our dashboard. So please do so
the config seems right. I just tried it with a hard coded twilio token, and i do see the access token payload update
So i think the code is fine.. it's probably something else that's wrong then 😦
m
Oh thanks for telling me about the API key. I will change it right away. That's interesting, I will do some more debugging I guess. Thanks for the help
r
cool