Replies: 3 comments 1 reply
-
Any comments on my question? Thanks! |
Beta Was this translation helpful? Give feedback.
-
I got stuck at the same position and the only solution I found was to put an if block before returning the protected content. I have been playing with the example code of next-auth if you are confused about the code below. Everything else I tried failed because the session object returns undefined unless someone logs in. Only after someone logs in you get to access the obj params and only then you can check if the user is eligible to see the page or not.
I hope this helps. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/nextauthjs/next-auth-example/blob/main/pages/api/examples/protected.js
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
** Question **
How to implement admin authentication along the usual authentication?
** Description **
I would like to allow users to sign in using one of the providers (GitHub etc.). But I also want an admin page for my own site, where only a few people with admin privilege have access to. I'm not sure about the best way to go about it with NextAuth.
A more general question: Is it possible with NextAuth to have two sign in places, where one uses a provider (like GitHub etc.) and the other one uses Credentials (for admin)?
Feedback
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions