Giter Club home page Giter Club logo

loopback-component-roles's Introduction

loopback-component-roles

Component for Loopback, adding roles management to your User model. bitHound Dependencies

More about Loopback components here

## Usage

npm install --save loopback-component-roles

In component-config.json add

"loopback-component-roles": {
    "userModel": "MyUser",
    "aclModel": "MyACL",
    "roleModel": "MyRole",
    "roleMappingModel": "MyRoleMapping",
    "adminEmail": "[email protected]"
}
  • Where My* are the name of your custom models (by default, build-in model will be used).
  • adminEmail is the mail you want for admin account (by default, [email protected])
  • All options are optional

Warnings

  • If you want to see the method added in the explorer, take care of load the loopback-component-explorer after loopback-component-roles in component-config.json

What does this component do?

  • Create a role admin if not exist
  • Create an admin user (password by default: admin) if not exist
  • Give role admin to admin user
  • Create /!\ persisted /!\ ACLs to allow admin manipulate roles and users
  • Add remote methods addRole, removeRole, findByRole, getAllRoles, getPersistedRoles to User model

loopback-component-roles's People

Contributors

ariskemper avatar aureliev avatar purpleorwel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

loopback-component-roles's Issues

Unhandled rejection ValidationError: The `Role` instance is not valid. Details: `name` already exists (value: "admin").

The following appears on every server start
not shure if it is an issue but it is making a lot of mess in logs for shure

Unhandled rejection ValidationError: The `Role` instance is not valid. Details: `name` already exists (value: "admin").
    at C:\work\site\siteLoop\node_modules\loopback-datasource-juggler\lib\dao.js:1164:16
    at ModelConstructor.<anonymous> (C:\work\site\siteLoop\node_modules\loopback-datasource-juggler\lib\validations.js:513:13)
    at ModelConstructor.next (C:\work\site\siteLoop\node_modules\loopback-datasource-juggler\lib\hooks.js:83:12)
    at done (C:\work\site\siteLoop\node_modules\loopback-datasource-juggler\lib\validations.js:510:25)
    at C:\work\site\siteLoop\node_modules\loopback-datasource-juggler\lib\validations.js:588:7
    at ModelConstructor.<anonymous> (C:\work\site\siteLoop\node_modules\loopback-datasource-juggler\lib\validations.js:382:5)
    at C:\work\site\siteLoop\node_modules\loopback-datasource-juggler\lib\dao.js:2013:9
    at C:\work\site\siteLoop\node_modules\async\dist\async.js:1012:9
    at C:\work\site\siteLoop\node_modules\async\dist\async.js:359:16
    at iteratorCallback (C:\work\site\siteLoop\node_modules\async\dist\async.js:935:13)
    at C:\work\site\siteLoop\node_modules\async\dist\async.js:843:16
    at C:\work\site\siteLoop\node_modules\async\dist\async.js:1009:13
    at buildResult (C:\work\site\siteLoop\node_modules\loopback-datasource-juggler\lib\dao.js:1979:11)
    at C:\work\site\siteLoop\node_modules\loopback-datasource-juggler\lib\dao.js:1993:13
    at doNotify (C:\work\site\siteLoop\node_modules\loopback-datasource-juggler\lib\observer.js:99:49)
    at doNotify (C:\work\site\siteLoop\node_modules\loopback-datasource-juggler\lib\observer.js:99:49)

Add an example

need an example, as i want to use this, but not much information is not stated at readme.

Create options

  • create or not admin user
  • choose admin user name
  • create or not admin role
  • choose admin role

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.