GithubHelp home page GithubHelp logo

Permission check API about express-acl HOT 1 CLOSED

nyambati avatar nyambati commented on September 15, 2024
Permission check API

from express-acl.

Comments (1)

nyambati avatar nyambati commented on September 15, 2024

@kahwooi
This module does not have such method or API as it is basically a middleware between the client and your resources. It will only allow traffic to endpoints that have been allowed in your configuration. When you make a request to an Unauthorised endpoint, you will get a JSON response as below.

{
  "status": "Access denied",
  "success": false,
  "message": "Unautorised Access"
}

You can use this JSON object to disable rendering a view. Frameworks like Angular provides hooks that can tap into to render a view only when certain conditions are fulfilled e.g ui-router resolve.

Based on your scenario I would recommend you use roles attached to each user to achieve this e.g

function renderSalesView(user) {
  let allowed = ['admin', 'sales'];
  return (allowed.includes(user.role)) ? true : false;
}

You can decide to render the new sales page only when the method returns true. With this you can achieve the same results without making any request to your server.

from express-acl.

Related Issues (20)

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.