felipe.franco
TTCTheo's Typesafe Cult
•Created by felipe.franco on 7/26/2023 in #questions
Check DB or update session when DB role changes
This is my initial implemetation, works great:
13 replies
TTCTheo's Typesafe Cult
•Created by felipe.franco on 7/26/2023 in #questions
Check DB or update session when DB role changes
YES! thank you, that is exactly what I needed, I was using JWT to protect the routes using middleware.ts, but that was the wrong choice.
Found a great article about protecting routes using a "AuthGuard" component:
https://dev.to/ivandotv/protecting-static-pages-in-next-js-application-1e50
13 replies
TTCTheo's Typesafe Cult
•Created by felipe.franco on 7/26/2023 in #questions
Check DB or update session when DB role changes
I thought about doing a wrapper component with the getServerSideProps check, and than wrapping the whole app with it, is there a cleaner way to do it?
13 replies
TTCTheo's Typesafe Cult
•Created by felipe.franco on 7/26/2023 in #questions
Check DB or update session when DB role changes
Is there a way to do this without using getServerSideProps on every route? (using /pages directory)
13 replies
TTCTheo's Typesafe Cult
•Created by felipe.franco on 7/26/2023 in #questions
Check DB or update session when DB role changes
13 replies
TTCTheo's Typesafe Cult
•Created by felipe.franco on 7/26/2023 in #questions
Check DB or update session when DB role changes
13 replies
TTCTheo's Typesafe Cult
•Created by felipe.franco on 7/26/2023 in #questions
Check DB or update session when DB role changes
13 replies
TTCTheo's Typesafe Cult
•Created by felipe.franco on 7/26/2023 in #questions
Check DB or update session when DB role changes
Currently I have this middleware.ts that checks the user role and the companies that the user has access to.
The roles are:
- USER : Can access only the /dashboard/[companyId] route if the companyId is present in the token.companiesIds;
- ADMIN: Currently the same access as the USER role (other routes will be implemented in the future);
- SUPERADMIN: Can access all /dashboard/[companyId] independent if the companyId is present in their token.companiesIds.
All requests that try to access "/" or a /dashboard/[companyId] are redirected to /dashboard/[companyId] using the first companyId in token.companiesIds.
13 replies