Hello everyone.
I am developing a web app using Next 13 and the App Router. What I Want to achieve is a simple application where there are 2 types of users:
User 1 → Authenticated via Auth0
User 2 → Authenticated via Auth0 and a special dashboard (like in /account/web3) where they can access their web3 wallet under the hood.
Since the user in order to access to /account/web3 is already authenticated (via google for example), I want that when he clicks the button “access wallet” the function web3auth.connect() is executed without ask him again the authentication (since as I said, is already authenticated)
Unfortunately it requires the tokenId (JWT).
I have managed to access the tokenId via “await getSession” but I get in the console “nextjs-auth0 is attempting to set cookies from a server component”. Moreover, after the first successful login I tried to refresh the page and the session was gone. Obviously, re-authenticating throw the error that the JWT has already been used.
How do you think I can solve this problem? What is the best practice to get the JWT and pass it to the connect function?
Here a snippet of my code (session is passed as props from the parent server component)
const createWallet = async () => {
const idToken = session.idToken!
const subVerifierInfoArray = [
{
verifier: "XXXXX",
idToken: idToken,
},
];
const tmpProvider = await web3authSfa.connect({
verifier,
verifierId: session.user.sub,
idToken: idToken,
subVerifierInfoArray,
});
if (tmpProvider) {
setProvider(tmpProvider)
}
}
Thank you