Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please help how can i manage menu by role user ? #245

Open
Juckky00 opened this issue Dec 24, 2017 · 1 comment
Open

Please help how can i manage menu by role user ? #245

Juckky00 opened this issue Dec 24, 2017 · 1 comment

Comments

@Juckky00
Copy link

I want to show want to show different menu by role of user when insert role like this.
can guide me for something.
thank you.
/store/modules/menu/index.js

const state = {
  items: [
    person,
    {
      name: 'Domain',
      path: '/domain',
      meta: {
        auth: true,
        icon: 'fa-briefcase',
        link: 'domain/domainform.vue'
      },
      roles: ['admin'],
      component: lazyLoading('domain/domainform')
    }
  ]
}
@che1974
Copy link

che1974 commented Jan 5, 2018

Add custom attribute role
{
name: 'Перелік установ',
path: '/config/payers',
role: 777,
meta: {
label: 'Перелік установ',
link: 'config/Payers.vue',
auth: {
roles: 777,
redirect: { name: 'admin' },
forbiddenRedirect: '/403'
}
},
component: lazyLoading('config/Payers')
}


in component check with attribute and compare with user role
<expanding v-if="item.children && item.children.length"> <ul v-show="isExpanded(item)"> <li v-for="subItem in item.children" v-if="subItem.role == $auth.user().role "> <router-link :to="generatePath(item, subItem)" v-bind:role={item}> {{ subItem.meta && subItem.meta.label || subItem.name }} </router-link> </li> </ul> </expanding>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants