I am writing a Nuxt site which will allow users to be members of a team. Each member will have a role (Member, Manager, Owner etc.) which I can return from the data source for each member (or user) as I am writing the backend here too.
How do I go about restricting access to certain pages based on the user's role within that team?
I'm guessing the first step is to try and write a custom middleware that I can use for the pages I want to restrict:-
export default function ({ $auth, redirect }) {
// do the check here
}
but I'm not sure what the best way to get at the user's role for that specific page's team from there.
I've seen people recommending to use the scope key of nuxt-auth but that doesn't look too good for team-specific roles like this so now I'm a bit lost.
Any ideas?