Assignments and permissions with Nuxtjs and Vuex

Asked

Viewed 58 times

0

Question

- Is there a more appropriate approach / to deal with the release of access to page content depending on the profile of a logged-in user using Vuex and Nuxt?

What I want to do

When logging into the admin, depending on the profile of the logged-in user (Example: User, Producer, Buyer, Deliverer), a list is presented with links in the sidebar component - the user may have multiple profiles (Example: Producer and Deliverer, etc)

As I’m thinking of doing at the moment

I thought about saving the user’s profile(s) logged in to an array in the state and then using this information in the component. In this case I would have the list with all the links in the Component and would do a v-if to present the content according to the profile.

And also would have some middleware to control access to the pages.

export const state = () => ({
  perfilDoUsuario: [ 'Usuario', 'Produtor' ] // ou por exemplo [ 'Usuário', 'Produtor', 'Comprador' ]
  • Maybe the Vue-Kindergarten be a good alternative.

  • I took a look, but I don’t know how I would adapt it to my need. I intend to free access to certain parts of the tool based on content that may exist in certain fields of the user object - example: I would take this information in user authentication - productsDoUsuario: [ idProdut1, idProduct2 ] - existing products in the array, I would release the producer content to the user. I thought about doing it like this: set something as usersTemProducts as true (Mutation) and then make a getter like usersProducer to use in the components and page.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.