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

@dynapp/webc-api-user

v1.1.0

Published

Vuex component to handle user

Downloads

10

Readme

User vuex module

Implement

Install

yarn add @dynapp/webc-api-user

Setup

router.js

import Router from 'vue-router'
import store from './store'

Vue.use(Router);

const router = new Router({
  routes: []
});
router.beforeEach((to, from, next) => {
  store.dispatch('user/checkRouteAccess', {to, from, next});
});

export default router;

store/index.js

import Vue from 'vue'
import Vuex from 'vuex'
import createUserModule from '@dynapp/webc-api-user'

Vue.use(Vuex);

export default new Vuex.Store({
  modules: {
    user: createUserModule()
  }
});

view/component script

export default {
  data () {
    return {
      username: '',
      password: ''
    }
  },
  computed: {
    loginStatus () {
      return this.$store.getters['user/loginStatus'];
    }
  },
  methods: {
    login () {
      this.$store.dispatch('user/login', {
        username: this.username,
        password: this.password
      }).then(() => {
        // Login successful, do something
      });
    }
  }
}

API

Options

Options are passed as a dictionary to the createUserModule funcction.

  • oidc-login: Boolean Whether app should use oidc (open id connect) login, aka. single sign on or not. Default is false.
  • mode: String The current development mode. Defaults to process.env.NODE_ENV if it's available, otherwise defaults to development.

Getters

user/currentUser

Get current user

this.$store.getters['user/currentUser'];

user/loginStatus

Get current login status

Possible values are:

  • INVALID - Attempted login but server responded with 401
  • PENDING - A request to log in, or out, is in the air
  • LOGGED_IN - Logged in
  • LOGGED_OUT - Logged out
this.$store.getters['user/loginStatus'];

user/hasRole

Check if user has role. Returns a function that expects a role to be passed. Returns a Boolean.

this.$store.getters['user/hasRole']('<some_role>');

Actions

user/checkRouteAccess

Used in router.beforeEach. Takes a dictionary with router.beforeEach's parameters as parameter.

If user is tagged as logged in locally it just lets him/her through to next route. If not, a check is made if the user has a session on the server. If the user don't have a session the user is taken to the login view.

store.dispatch('user/checkRouteAccess', {to, from, next});

user/login

Make a login request to the server. Returns a Promise.

this.$store.dispatch('user/login', {
	username: this.username,
	password: this.password
});

user/logout

Make a logout request to the server. Returns a Promise.

this.$store.dispatch('user/logout');

user/changePassword

Make a request to change the currently logged in user's password.

Commits loading changes on topic user.changepassword.

Returns a Promise.

this.$store.dispatch('user/changePassword', {
  password: this.oldPassword,
  new_password: this.newPassword
});

Project setup

yarn install

Lint and fix files

yarn run lint