Giter Club home page Giter Club logo

ng-access-control's Introduction

ng-access-control

Role and permission based access control for your angular applications

 Dependencies

 Installation

 bower

bower install ng-access-control --save

 Usage

##### Permission Syntax

    {
      "name": "ACCOUNTANT",
      "permissions": {
        "Contract": {
          "__self": {
            "READ": true,
            "WRITE": true,
            "UPDATE": true
          },
          "__global": {
            "READ": false,
            "WRITE": false,
            "UPDATE": true
          },
          "status": {
            "READ": false,
            "WRITE": false,
            "UPDATE": false
          },
          "job": {
            "title": {
              "READ": true,
              "UPDATE": false
            }
          }
        },
        "Employee": {
          "__self": {
            "READ": true,
            "WRITE": true,
            "UPDATE": true
          },
          "__global": {
            "READ": false,
            "WRITE": false,
            "UPDATE": true
          },
          "search": {
            "READ": true,
            "WRITE": false,
            "UPDATE": false
          }
        }
      }
    }

##### Usage in Application

    app.run(['ngAcl', function (ngAcl) {
    
      // Set the ACL permission. which you'd fetch from an API or something.
      
      //populate the permission either a single object or an array in the
      //form of above syntax
      ngAcl.populatePermission(permission);
    
      ngAcl.populateUserRoles('ACCOUNTANT');

      // Attach the member role to the current user
      ngAcl.setCurrentRole('ACCOUNTANT');
    
    }]);

##### Usage in UI as a directive

Directive will take care of the show and hide of the element according to the permissions provided.

    <!--For update/write purpose mention the mode-->
    <!--For read purpose no need to mention the mode-->
    <!--is-author attribute is used to tell that user is the author of the object-->
    <input acl="Employee.search" mode="UPDATE" is-author="false" type="text" ng-model="vm.searchKeyword" class="form-control" name="email" placeholder="Enter email">

##### Usage of ngAcl service

Pass in the resource name and .can method will return true or false if the resource is allowed of not.

    let allower  = ngAcl.can('Employee_Create')

ng-access-control's People

Contributors

sharique-hasan avatar

Stargazers

Hamzah Waqas avatar Muhammad MuZzammil avatar

Watchers

James Cloos avatar  avatar

Forkers

syed-maaz

ng-access-control's Issues

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.