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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-user-management

v0.8.1

Published

A module to provide user management in web applications

Downloads

4

Readme

User Management for React Applications

This module is still in development stage and not to be used just yet

The module provides react components that can be added in a react application to create/view users, roles and permissions. The module also provides APIs to do the following:

  • Check if a user is currently logged in
  • Get the currently loggged in user
  • Add a permission on an object programatically
  • Check if a user is permitted to perform one of the CRUD operations on an object

Following react components are exported:

  • ManageUsers - Component where you can see the current users and add new users
  • ManageRoles - Component wher you can see the current roles and add new roles
  • ManagePermissions - Component where you can see current group level permissions and add new group level permissions
  • EditUser - Component where you can add/edit a user
  • EditRole - Component where you can add/edit a role
  • EditPermission - Component where you can add/edit a permission
  • Login - Component to allow a user to log in
  • SignUp - Component to allow a user to sign up

Right now, the above components need to be hooken into a react-router component. Check out lib/App.js for example usage

Things to note

  • The module is currently using Parse as the backend. You will need to create a Parse application and provide the JAVASCRIPT_KEY and APPLICATION_KEY in the base html file. Check index.html for example usage
  • EditUser component needs to be linked to URL /users/new as done in the App.js because that is how it is configured in the ManageUsers component. Similarly, follow the route paths for EditRole and EditPermission component as done in the App.js
  • ManagePermissions component should be passed in a function 'targetObjectsCallback' which should return a list of strings. These are the target objects on which users can define permissions. See App.jsx for example usage

Following APIs are exported:

  • currentUser() - Returns the currently logged in user or null

  • logoutUser() - Logs out the currently logged in user

  • addUserPermission(permission) - Add a permission on an object for a user. The permission object is specified as below:

    {
      targetObject: string (ID of the object on which permission should be applied)
      username: string (username on which the permission applies)
      operations: array[string] (CRUD operations ['create', 'read', 'update', 'delete'])
      action: string (Action to be taken i.e. 'allow' or 'deny')
    }
  • checkPermission(targetObject, operation, username) - Checks if the user is allowed to perform the specified operation on the target object. Returns 'allow' or 'deny' based on the current permissions defined in the system. Below is the description of each argument:

      targetObject: string (ID of the object on which permission should be applied)
      username: string (username on which the permission applies)
      operation: string (CRUD operation ['create', 'read', 'update', 'delete'] which need to be checked)

    Below are the rules to check if the return value should be 'allow' or 'deny'

    • If atleast one permission which denies the operation by the user on the target object, then 'deny' is returned
    • If no permissions are found that applies to the combination of 'targetObject', 'username' and 'operation', 'deny' is returned
    • If none of the above conditions are true, then 'allow' is returned