Mohammed Shoeb
Mohammed Shoeb

Reputation: 51

hiding the vue routes

I have my vue routes as

const ifAuthenticated = (to, from, next) => {
  if (store.getters.isAuthenticated) {
    next()
    return
  }
  next('/login')
}

const checkAgentPermissions = () => {
  return false
}

export const routes = [
 {
  path: '/users',
    beforeEnter: ifAuthenticated,
    component: Layout,
    meta: { title: 'Agent Onboarding', icon: 'address-card' },
    hidden: checkAgentPermissions,
    children: [
      {
        path: '',
        name: 'Users',
        component: () => import('@/views/users/index.vue')
      },
      {
        .....some more childrens
      }
    ]
 }
]

but hidden is always true, when called through functions. and if i change the option hidden from checkAgentPermissions to false

 hidden: false // works perfectly

why function doesn't return false, actually i need to do some check in fn and then return true/false depending on that.

forEach route i am rendering them in vue component by checking if hidden is true/false.

Upvotes: 0

Views: 1126

Answers (1)

TsaiKoga
TsaiKoga

Reputation: 13394

try to execute your hidden function:

hidden: checkAgentPermissions(),
children: [
...

Upvotes: 2

Related Questions