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

TypeError: b.includes is not a function #309

Closed
lantu-group opened this issue Aug 7, 2021 · 8 comments · Fixed by #310
Closed

TypeError: b.includes is not a function #309

lantu-group opened this issue Aug 7, 2021 · 8 comments · Fixed by #310
Assignees
Labels
bug Something isn't working released

Comments

@lantu-group
Copy link

At same env, use m = r.act == 'In' && r.sub in "('root', 'guest')" matchers is ok, but is i adjust conditions location: r.sub in "('root', 'guest')" as first location, eg: m = r.sub in "('root', 'guest')" && r.act == 'In', and then got error: TypeError: b.includes is not a function

The below is my test codes

const fs = require('fs')
const path = require('path')
const Casbin = require('casbin')

const model1Text = `[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = r.act == 'In' && r.sub in "('root', 'guest')"`


const model2Text = `[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = r.sub in "('root', 'guest')" && r.act == 'In'`

;
(async () => {
  // initial models
  const path1 = path.resolve(__dirname, './model1.conf')
  const path2 = path.resolve(__dirname, './model2.conf')
  fs.writeFileSync(path1, model1Text)
  fs.writeFileSync(path2, model2Text)

  // loading enforcer
  const enforcer1 = await Casbin.newEnforcer(path1)
  const enforcer2 = await Casbin.newEnforcer(path2)

  // test
  const result1 = await enforcer1.enforce('root', {}, 'In')
  const result2 = await enforcer2.enforce('root', {}, 'In')
  console.log('result1 : ', result1) // true
  console.log('result2 : ', result2) // throw new error
})();
@hsluoyz
Copy link
Member

hsluoyz commented Aug 7, 2021

@Zxilly @Gabriel-403

@hsluoyz hsluoyz self-assigned this Aug 7, 2021
@hsluoyz hsluoyz added the question Further information is requested label Aug 7, 2021
@Gabriel-403
Copy link
Contributor

@Zxilly @Gabriel-403

Looking for problems

@Zxilly
Copy link
Contributor

Zxilly commented Aug 7, 2021

@Gabriel-403 () in js didn't create an array. And includes function didn't exist. That's the problem.

@lantu-group
Copy link
Author

So ~ Are you ready this project for production ?

@Zxilly
Copy link
Contributor

Zxilly commented Aug 8, 2021

@lantu-group This library is production-ready. However, there are some missing documents.
In this issue, you should use in on a js array. like ['root', 'guest']

@Gabriel-403
Copy link
Contributor

@lantu-group We will try our best to solve this problem, but it will take some time

@hsluoyz hsluoyz added bug Something isn't working and removed question Further information is requested labels Aug 8, 2021
@lantu-group
Copy link
Author

@lantu-group We will try our best to solve this problem, but it will take some time

OK~ Just do it.

@github-actions
Copy link

🎉 This issue has been resolved in version 5.11.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants