简体   繁体   中英

Vue.js components + Laravel right management

I'm unsure how to procede with using Vue single file components alongside Laravel's right management plugins. In general I'm loading the components on different pages, however different actions in components require different rights available, and passing the available rights directly to component seems kind of unsafe. What would be the correct approach here?

If you are using the blade template together with laravel gates engine to render your views, you could pack the component inside a can statement

@can('view-component', 'component-name')
  <custom-vue-component></custom-vue-component>
@endcan

Specific use regarding permission checking in blade can be found here , general authorization info here and info about the gates [here] https://laravel.com/docs/5.4/authorization#gates() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM