Auth0 middleware session updates
Unanswered
Sloth bear posted this in #help-forum
Sloth bearOP
With nextjs-auth0 v3 I was using api routes (+afterCallback) to fetch all the data I need for the user and put it to the session object
Now I need to upgrade nextjs v14 => v15 and I have to use nextjs-auth0 v4 where they changed the workflow
I can't use Prisma client in the middleware and beforeSessionSaved hook (from auth0 configuration)
I can create an API endpoint and pass some parameters like email or id to identify a user, but this endpoint won't be protected in any way, cause I have session object in the beforeSessionSaved hook, but there is nothing in the route handlers yet and theoretically it will be possible to get info for any user
How and where I should request additional information for the user from my postgres db?
export const GET = handleAuth({
callback: handleCallback({ afterCallback }),
login: handleLogin({
authorizationParams: { scope: 'openid profile email name' },
}),
});
Now I need to upgrade nextjs v14 => v15 and I have to use nextjs-auth0 v4 where they changed the workflow
In v4, the Auth0 middleware is a central component of the SDK. It serves a number of core functions such as registering the required authentication endpoints, providing rolling sessions functionality, keeping access tokens fresh, etc.
When configuring your application to use v4 of the SDK, it is now required to mount the middleware
I can't use Prisma client in the middleware and beforeSessionSaved hook (from auth0 configuration)
I can create an API endpoint and pass some parameters like email or id to identify a user, but this endpoint won't be protected in any way, cause I have session object in the beforeSessionSaved hook, but there is nothing in the route handlers yet and theoretically it will be possible to get info for any user
How and where I should request additional information for the user from my postgres db?