Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,17 +321,17 @@ await user.permissions().fetch()

Syntax:

`and (&&)` - administrator && moderator
`and` - administrator,and,moderator

`or (||)` - administrator || moderator
`or` - administrator,or,moderator

`not (!)` - administrator && !moderator
`not` - administrator,and,not,moderator

```js
// check roles
Route
.get('/users')
.middleware(['auth:jwt', 'is:(administrator || moderator) && !customer'])
.middleware(['auth:jwt', 'is:(administrator,or,moderator),and,not,customer'])

// check permissions
Route
Expand Down
5 changes: 4 additions & 1 deletion src/Middlewares/Is.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ class Is {
async handle ({ auth }, next, ...args) {
let expression = args[0]
if (Array.isArray(expression)) {
expression = expression[0]
expression = expression.join(' ')
}
expression = expression.replace(' or ', ' || ')
expression = expression.replace(' and ', ' && ')
expression = expression.replace(' not ', ' !')
const is = await auth.user.is(expression)
if (!is) {
throw new ForbiddenException()
Expand Down