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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yacinthos/loopback-component-user-manager

v0.1.0

Published

User manager components for Loopback

Downloads

10

Readme

loopback-component-user-manager

User manager components for Loopback.

Model relations

User Model

A User have one group

User belongsTo a Group


{
  "name": "user",
  "base": "User",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "firstname": {
      "type": "string",
      "required": true
    },
    "lastname": {
      "type": "string",
      "required": true
    },
    "photo": {
      "type": "string",
      "required": false
    }
  },
  "validations": [],
  "relations": {
    "accessTokens": {
      "type": "hasMany",
      "model": "accessToken",
      "foreignKey": "userId",
      "options": {
        "disableInclude": false
      }
    },
    "group": {
      "type": "belongsTo",
      "model": "group",
      "foreignKey": "groupId",
      "options": {
        "disableInclude": false
      }
    }
  },
  "acls": [
    {
      "accessType": "READ",
      "principalType": "ROLE",
      "principalId": "$everyone",
      "permission": "ALLOW"
    }
  ],
  "methods": {}
}

Group Model

A user Group can have many roles

Group hasMany Roles


{
  "name": "group",
  "base": "PersistedModel",
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "id": {
      "type": "string",
      "id": true
    },
    "name": {
      "type": "string",
      "required": true
    },
    "description": {
      "type": "string",
      "required": true
    }
  },
  "validations": [],
  "relations": {
    "roles": {
      "type": "hasMany",
      "model": "role",
      "foreignKey": "groupId",
      "through": "groupRoleMapping",
      "options": {
        "disableInclude": false
      }
    }
  },
  "acls": [],
  "methods": {}
}

Role Model

A Role can be use by many groups

Role hasMany Group

{
  "name": "role",
  "base": "Role",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {},
  "validations": [],
  "relations": {
    "principals": {
      "type": "hasMany",
      "model": "RoleMapping",
      "foreignKey": "roleId"
    },
    "groups": {
      "type": "hasMany",
      "model": "group",
      "foreignKey": "roleId",
      "through": "groupRoleMapping",
      "options": {
        "disableInclude": false
      }
    }
  },
  "acls": [
    {
      "accessType": "*",
      "principalType": "ROLE",
      "principalId": "$everyone",
      "permission": "DENY"
    },
    {
      "accessType": "WRITE",
      "principalType": "ROLE",
      "principalId": "$write_role",
      "permission": "ALLOW"
    },
    {
      "accessType": "READ",
      "principalType": "ROLE",
      "principalId": "$read_role",
      "permission": "ALLOW"
    }
  ],
  "methods": {}
}

groupRoleMapping Model

groupRoleMapping is a through Relation Model for the Many to Many relation between Group and Roles

groupRoleMapping

{
  "name": "groupRoleMapping",
  "base": "PersistedModel",
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "id": {
      "type": "string",
      "id":true
    }
  },
  "validations": [],
  "relations": {
    "group": {
      "type": "belongsTo",
      "model": "group",
      "foreignKey": "groupId",
      "options": {
        "disableInclude": false
      }
    },
    "role": {
      "type": "belongsTo",
      "model": "role",
      "foreignKey": "roleId",
      "options": {
        "disableInclude": false
      }
    }
  },
  "acls": [],
  "methods": {}
}

Installation

$ npm install loopback-component-user-manager --save

Configuration

Unable loopback-component-user-manager

Add component configuration option in server/component-config.json.

"loopback-component-user-manager": {
    "userModel": "user",
    "roleModel":"role",
    "groupModel":"group"
  }
  • Options

userModel: must be the name of the user model

roleModel: must be the name of the role model

groupModel: must be the name of the group model

Setup models loopback-component-user-manager model source

  • Add model source loopback-component-user-manager/models in server/model-config.json under sources option.

  • Add user, group, role, groupRoleMapping models configuration in server/model-config.json

{
  ...,
  "_meta": {
      "sources": [
        ...,
        "loopback-component-user-manager/models",
        ...
      ],
      ...
  },
  "role": {
      "dataSource": "db",
      "public": true
   },
  "group": {
    "dataSource": "db",
    "public": true
  },
  "groupRoleMapping": {
    "dataSource": "db",
    "public": true
  },
  "ACL": {
    "dataSource": "db",
    "public": false
  },
  "RoleMapping": {
    "dataSource": "db",
    "public": false,
    "options": {
      "strictObjectIDCoercion": true
    }
  }
  ...
}

Extending models

You can extend loopback-component-user-manager built-in models by follow Loopback extending models tutorial.

After extending, change loopback-component-user-manager option according to your models