Skip to main content

Front-end Permissions: Show/Hide Buttons

Premium
3 min read
Vitalii avatar

I think there's a typo: we should use page.props.permissions instead of page.props.auth.permissions here

const can = (permission) => { return page.props.permissions.includes(permission) }

David Lun avatar

why do you think that way?

Jakub Gazdowicz avatar

Hello, how can i use this can() method in 'script' section? For example i have AppMenu.vue component in which i manage my menu buttons for routing, and i want to hide some of them depends on permission. This example throws undefined error and i don't understand why. (rewrite to export default function can() solves this problem - works in script and template)