Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to get action? #69

Open
fdorantesm opened this issue Apr 15, 2019 · 2 comments
Open

Is there a way to get action? #69

fdorantesm opened this issue Apr 15, 2019 · 2 comments
Labels

Comments

@fdorantesm
Copy link

Hi.

I'm using a middleware grouping role permissions, i got permissions, attributes and role except action.

/**
   * Middleware to grant or deny products creation.
   *
   * @param {Request} req
   * @param {Response} res
   * @param {Function} next
   */
  static async canCreateProducts (req, res, next) {
    const permission = User.canCreateProducts(req.acl.role)
    console.log({ permission: permission.action })
    if (permission.granted) {
      req.acl = { ...(req.acl || {}), ...permission.attributes }
      next()
    } else {
      res.boom.forbidden()
    }
  }
@onury
Copy link
Owner

onury commented Apr 15, 2019

Hi. Since permission is checked "for" an action (and resource), code should be aware of it.
Per your abstraction; canCreateProducts method indicates action is create.

@fdorantesm
Copy link
Author

fdorantesm commented Apr 15, 2019 via email

@onury onury added the request label Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants