To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/Tuomo/. The first 200 of you will get 20% off Brilliant’s annual premium subscription.
Thanks a lot Tuomo for this video. It's a lot clearer to me now how to implement role based authorization in Next.js. My only question is how to do this with email password authentication instead of Github authentication. Greetings, Anthony
Thanks for clarifying the api routing for next auth! I was wondering why nextauth wasn't working with my other new api routes in the app folder. This and your earlier nextauth for nextjs13 tutorials are the most in depth tutorials on the new app router features i've seen so far
Thanks for this bro, Usually the username,email,image only will store in database for the backend? and the exp date is not usually included in the frontend part when sending the data to the backend?
Hello! Could you please advise me how to set up role issuance in a production application? After all, in the video there was a rigid binding by hand. Maybe it should be connected to a database or something like that? Could you please answer this question or make a detailed video on this topic? Thanks!!!
i am new to backend web development, i got the machinisim of how this work logically but was a bit confused. If i m correct right now the role assignment is hardcoded right? in real world, how would we handle and assign role to a user? it sounded like its going to be very complicated and required to set up admin pannel and check role from user database?
Tuomo, I have my middleware file in the root of my project exactly as you have laid out in this tutorial, using next 13.2.4 and next auth ^4.22.0. If i attempt to access a page that is blocked by the middleware, I login but the callback is stuck in a loop on the same login screen. is this an issue the the version of next/next-auth?
There is a little problem with that approach, if of any importance to anybody. withAuth doesn't work on the Edge Network (which totally different from the browser by the way), and guess what if you don't run serverless this will be your second main option. but thanks any way
Love your tutes. Helped me out a few times now. Having a small issue with this one tho. Got it mostly working, but for some reason the admin pages are only blocked if I go directly to the url using the address bar... following a Link however allows me access to the protected pages. Any ideas? Im just using the standard nextjs Link components, but they appear to be ignoring the middleware.
Thanks, great to hear you have liked the videos! The problem sounds weird, does it still ignore the middleware after sev server reboot and hard refresh / clearing browser cache?
Is this middleware strategy compatible with client components or only with server components? Can both kinds of components coexis using this middleware strategy?
To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/Tuomo/. The first 200 of you will get 20% off Brilliant’s annual premium subscription.
Thanks a lot Tuomo for this video. It's a lot clearer to me now how to implement role based authorization in Next.js. My only question is how to do this with email password authentication instead of Github authentication. Greetings, Anthony
this video really help a lot for me to understand the most basic structure of Role-based access control (RBAC) of next js.
Thank you so much!!
Glad to hear that!
Sorry sir I wil watching your video very late because I am few days sick. Love from India ❤
Cheers!
Thanks for clarifying the api routing for next auth! I was wondering why nextauth wasn't working with my other new api routes in the app folder.
This and your earlier nextauth for nextjs13 tutorials are the most in depth tutorials on the new app router features i've seen so far
Thank you that’s great to hear that the videos have been helpful!
Sir, suppose i have 2 role in my project admin and superadmin. Now how to protect admin from superadmin and superadmin to admin
Im afraid Im not sure what you mean
thanks your english is very good can all finnish speak this well english
Thank you! I dont know, I guess it may vary!
Thanks for this bro, Usually the username,email,image only will store in database for the backend? and the exp date is not usually included in the frontend part when sending the data to the backend?
Hello! Could you please advise me how to set up role issuance in a production application? After all, in the video there was a rigid binding by hand.
Maybe it should be connected to a database or something like that? Could you please answer this question or make a detailed video on this topic?
Thanks!!!
Hello! Yeah I would probably get the information from a database in prod as u said in the example it was just hardcoded
i am new to backend web development, i got the machinisim of how this work logically but was a bit confused. If i m correct right now the role assignment is hardcoded right? in real world, how would we handle and assign role to a user? it sounded like its going to be very complicated and required to set up admin pannel and check role from user database?
Hi
How to add in next-intl .. because in middleware i am getting the issue.. please help me if possible
Thanks
Cheers!
Tuomo, I have my middleware file in the root of my project exactly as you have laid out in this tutorial, using next 13.2.4 and next auth ^4.22.0. If i attempt to access a page that is blocked by the middleware, I login but the callback is stuck in a loop on the same login screen. is this an issue the the version of next/next-auth?
I have the same problem
That's weird! Make sure you have the NEXTAUTH_SECRET and NEXTAUTH_URL correctly setup in the environment file, not sure but hopefully that helps!
thank you so much, I didn't know that middleware should be as the same level as app folder, I was putting it in the root and it wasn't working
Glad I could help!
The [...nextauth] file works in the app directory now.
Great!
Thank for this video
Cheers!
There is a little problem with that approach, if of any importance to anybody. withAuth doesn't work on the Edge Network (which totally different from the browser by the way), and guess what if you don't run serverless this will be your second main option. but thanks any way
Thank you!
Cheers!
Love your tutes. Helped me out a few times now. Having a small issue with this one tho. Got it mostly working, but for some reason the admin pages are only blocked if I go directly to the url using the address bar... following a Link however allows me access to the protected pages. Any ideas? Im just using the standard nextjs Link components, but they appear to be ignoring the middleware.
Thanks, great to hear you have liked the videos! The problem sounds weird, does it still ignore the middleware after sev server reboot and hard refresh / clearing browser cache?
how can I check role base for dynamic route
if(req.nextUrl.pathname === "/artist/[id]") {
//do something
}
can I use that above code
export const config = { matcher: ["/admin/:anything*"] };
Is this middleware strategy compatible with client components or only with server components?
Can both kinds of components coexis using this middleware strategy?
Yea you should be able to use both kind of components!
Really awsome
Cheers!
Hello Tuomo,
Thank you for the sharing the valuable information. Can you please share the code as well ?
Sure, it's here in the main branch: github.com/tumetus/next-js-middleware-role-auth-example
Would this work the same with Google?
It should yeah!
tanks for the video , can we have the source code ?
Sure, it's here in the main branch: github.com/tumetus/next-js-middleware-role-auth-example
It's a shame that simply having nextjs middleware is adding 100 ms overhead delay to every request of your app.....
I'm not sure if it adds that much to be honest, of course depends what kind of code is ran in the middleware
please attach link source github
Sure, it's here in the main branch: github.com/tumetus/next-js-middleware-role-auth-example
halar po hala title a ki likco ar ki dekico kisur sate kisu mill ny