npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@howiefh/vue-access-control

v0.0.4

Published

A Access Control Plugin for Vue.js.

Downloads

9

Readme

vue-access-control

Install

npm install @howiefh/vue-access-control -S

Quick Start

Add plugin in vue 2.

import Vue from 'vue'
import VueAccessControl from '@howiefh/vue-access-control'
import axios from 'axios'

// or simply
// import store from './store'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({})

Vue.use(VueAccessControl, {
  errorPage: '/403', // default: null. the path of error page. navigate to the error page when hasPermission(route.meta.permissions) is false.
  enableWildcard: true, // default: false. see more about wildcard permissions: https://shiro.apache.org/permissions.html#wildcard-permissions
  store,
  access() {
    return new Promise((resolve, reject) => {
      axios.post('/api/permissions').then(response => {
        const res = response.data
        // data structure
        // response.data:
        // {"data":{"userId":"howiefh","permissions":["app", "menu", "user:query:*"], "roles": ["admin"]}}
        if (!res.data) {
          reject('res.data is null')
        } else {
          resolve(res.data)
        }
      }).catch(err => reject(err))
    })
  }
})

Usage

Use functions or directives to check permissions

<template>
  <div>
    functions:
    <div v-show="$hasPermission('app')">$hasPermission('app')</div>
    <div v-show="$hasPermission(['app'])">$hasPermission(['app'])</div>
    <div v-show="$lacksPermission('user')">$lacksPermission('user')</div>
    <div v-show="$lacksPermission(['user'])">$lacksPermission(['user'])</div>
    <div v-show="$hasAnyPermissions(['app'])">$hasAnyPermissions(['app'])</div>
    <div v-show="$hasAnyPermissions(['user'])">$hasAnyPermissions(['user'])</div>
    <div v-show="$hasAllPermissions(['app', 'menu'])">$hasAllPermissions(['app', 'menu'])</div>
    <div v-show="$hasRole('app')">$hasRole('app')</div>
    <div v-show="$hasRole(['app'])">$hasRole(['app'])</div>
    <div v-show="$lacksRole('user')">$lacksRole('user')</div>
    <div v-show="$lacksRole(['user'])">$lacksRole(['user'])</div>
    <div v-show="$hasAnyRoles(['app'])">$hasAnyRoles(['app'])</div>
    <div v-show="$hasAnyRoles(['user'])">$hasAnyRoles(['user'])</div>
    <div v-show="$hasAllRoles(['app', 'menu'])">$hasAllRoles(['app', 'menu'])</div>
    directions:
    <div v-hasPermission="'app'">v-hasPermission="'app'"</div>
    <div v-hasPermission="['app']">v-hasPermission="['app']"</div>
    <div v-lacksPermission="'user'">v-lacksPermission="'user'"</div>
    <div v-lacksPermission="['user']">v-lacksPermission="['user']"</div>
    <div v-hasAnyPermissions="['app']">v-hasAnyPermissions="['app']"</div>
    <div v-hasAnyPermissions="['user']">v-hasAnyPermissions="['user']"</div>
    <div v-hasAllPermissions="['app', 'menu']">v-hasAllPermissions="['app', 'menu']"</div>
    <div v-hasRole="'app'">v-hasRole="'app'"</div>
    <div v-hasRole="['app']">v-hasRole="['app']"</div>
    <div v-lacksRole="'user'">v-lacksRole="'user'"</div>
    <div v-lacksRole="['user']">v-lacksRole="['user']"</div>
    <div v-hasAnyRoles="['app']">v-hasAnyRoles="['app']"</div>
    <div v-hasAnyRoles="['user']">v-hasAnyRoles="['user']"</div>
    <div v-hasAllRoles="['app', 'menu']">v-hasAllRoles="['app', 'menu']"</div>
    wildcard permissions:
    <div v-show="$hasPermission('user:query:*')">$hasPermission('user:query:*')</div>
    <div v-show="$hasPermission('user:query:1,2,3')">$hasPermission('user:query:1,2,3')</div>
    <div v-show="$lacksPermission('user:update')">$lacksPermission('user:update')</div>
  </div>
</template>

<script>

export default {
  name: 'App',
  methods: {
    foo() {
      if (this.$hasPermission(['menu'])) {
        this.$router.push({ path: '/menu' })
      }
    }
  }
}
</script>

Error Page

You can also use the error page components provided in this plugin.

import { Error403 } from '@howiefh/vue-access-control/dist/error-page.umd'
import '@howiefh/vue-access-control/dist/error-page.css'

const routes = [{ path: '/403', name: '403', component: Error403 }]

const router = new VueRouter({
  routes
})

Demo

git clone https://github.com/howiefh/vue-access-control.git
cd vue-access-control
yarn install
yarn serve