# user-groups-roles

> This modules defines user roles as according defined roles. This also ads prevalages to roles. Thus it returns the status of prevalage for every request. This is middlewere (express)",

Latest version **2.0.4** (published 2018-03-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install user-groups-roles
pnpm add user-groups-roles
yarn add user-groups-roles
bun add user-groups-roles
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2018-03-27 |
| First published | 2018-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Dr Umeesh R Bilagi |
| Maintainers | umeshbilagi |
| Keywords | user, roles, permmissions, authenticacian, login |

## Links

- npm: https://www.npmjs.com/package/user-groups-roles
- Repository: https://github.com/umeshramya/user-groups-roles
- Homepage: https://github.com/umeshramya/user-groups-roles#readme
- Issues: https://github.com/umeshramya/user-groups-roles/issues
- npm.io page: https://npm.io/package/user-groups-roles

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 2.0.4 (latest) — 2018-03-27
- 2.0.3 — 2018-03-27
- 2.0.2 — 2018-03-26
- 2.0.1 — 2018-03-26
- 2.0.0 — 2018-03-14
- 1.1.2 — 2018-02-21
- 1.1.1 — 2018-02-21
- 1.1.0 — 2018-02-21
- 1.0.7 — 2018-02-21
- 1.0.6 — 2018-02-20
- 1.0.5 — 2018-02-20
- 1.0.4 — 2018-01-13
- 1.0.3 — 2018-01-12
- 1.0.2 — 2018-01-11
- 1.0.1 — 2018-01-07
- … 1 more at https://npm.io/package/user-groups-roles/versions

## README

# user-groups-roles
![verson](https://img.shields.io/badge/version-2.0.4-green.svg)
![License](https://img.shields.io/badge/License-MIT-yellowgreen.svg)


This module is meant for creating user, groups or roles and privileges.

#### To install use this command
**npm i user-groups-roles**

## Usage

### create previleges
for creating privileges use createNewPrivileges method this has three arguments name of privilege description of privilege and defualt value for privilege

### get all privileges
use getAllPrivileges method to all privileges

### create roles 
create new role with method createNewRole. this method has one argument i.e name of role.

### get all roles
use getAllRoles to get all roles

### add privileges to roles
use  addPrivilegeToRole method to add privileges to roles. This has three arguments. role , privilege and value(value of privilege against defulat value in createNewPrivileges method)

### get role privileges with this method 
To get all privileges with value for a role use getRolePrivileges. This method accepts one argument i.e role. This method first gets set privileges for a role and further add up all privileges next in same array. So developer has to accept first come first privilege for the role.


## get value for given privilege and role for route 
role is role, url is route , method is GET, POST, PUT and DELETE
getRoleRoutePrivilegeValue = (role, url, method)

## get value for privilge and role inside bussiness logic
getRolePrivilegeValue = (role, curprivilege)

```

createNewPrivileges("create user", "This creats the new", false);
createNewPrivileges("delete user", "this deletes the ", false);
//privilege can be array  like createNewPrivileges(["/create_user", "POST"], "This creats the new", false);

createNewRole("admin");
createNewRole("editor");

console.log(getAllPrivileges());//outputs all privileges
console.log(getAllRoles());// outputs all roles

addPrivilegeToRole("admin","create user", true);
addPrivilegeToRole("admin", "delete user", true);


console.log(getRolePrivileges("admin"));

````

---
_Source: https://npm.io/package/user-groups-roles · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
