How to protect certain routes based on user privileges? #3147
-
Hello, For my application, paid users can access certain routes that free users cannot. I am currently storing the user privilege in the private metadata field of the Using I am using Next js with the app router. Any help would be appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @MrMoneyInTheBank! You can implement this functionality by storing the user privilege in the user's public metadata, which you can then embed in the session token as a claim. With that done, you will be able to check for the existence of the privilege in |
Beta Was this translation helpful? Give feedback.
Hey @MrMoneyInTheBank!
You can implement this functionality by storing the user privilege in the user's public metadata, which you can then embed in the session token as a claim. With that done, you will be able to check for the existence of the privilege in
afterAuth()
without performing a network request. Here are two guides on how to implement all of this: