Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get full session.user object in middleware? #2

Closed
mpresecan opened this issue May 6, 2024 · 1 comment
Closed

How to get full session.user object in middleware? #2

mpresecan opened this issue May 6, 2024 · 1 comment

Comments

@mpresecan
Copy link

I really like your starter kit and next-auth integration within payload. I am trying to get full user object into the middleware, but I failed in many different ways, so maybe you might have an idea how to get that.

The idea is that I can get a user.role field within middleware.

According to this post: nextauthjs/next-auth#9836 the idea is to extract entire auth.config into a separate file, just like you have, but with callbacks functions as well. But if the callback functions are added in config file, then the system brakes because it is dependend on node.js function... it seems to me that this is due to jwt method which calls dbUser, because calling local fetch functions in payload has some dependency on node enviroment.

Do you have idea how to get full user session inside of middleware? Thanks

@mpresecan
Copy link
Author

Now I figured out that there is edge.ts which contians getAuthJsToken method. This did the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant