@juicymedia/vuex-roles

1.0.7 • Public • Published

Vuex Roles and Permissions

A simple Vuex plugin for managing user roles and permissions.

Installation

NPM

npm i vuex-roles

Usage

Usage with Vue 2

// Import Vue and your Vuex store
import Vue from 'vue'; 
import store from './store';
import Roles from 'vuex-roles';

// Register the plugin, passing the store is required
Vue.use(Roles, { store });

// Create our Vue instance
const app = new Vue({
  el: '#app',
  store,
});

// Register some roles and permissions
app.$roles.setRoles(['admin']);
app.$roles.setPermissions(['users.create', 'users.delete']);

Directives

The v-role and v-permission directives can be applied to elements to display or remove it depending on whether the role/permission is set.

Example

<div v-role=''> I'm an admin </div>'

Methods

Package Sidebar

Install

npm i @juicymedia/vuex-roles

Weekly Downloads

1

Version

1.0.7

License

MIT

Unpacked Size

7.77 kB

Total Files

5

Last publish

Collaborators

  • adam.j.collins
  • danielhartuk
  • pkdavies