-
Notifications
You must be signed in to change notification settings - Fork 50
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 middleware or ( || ) operator not working #22
Comments
I have created a pull request with a possible fix/workaround |
No need on a workaround, just an update to the README.md feel free to merge #24 or just use @erikkallen 's PR when he corrects the README.md too. 👍 |
This way solve this problem:
|
It works!! Many thanks! |
Hi Erik Kallen, I have tried with || and or, for both I get Invalid Expression when I test from PostMan. Route.resource('/permissions', 'PermissionController').apiOnly().middleware(['auth', 'is:(administrator or moderator)']) Any suggestions with changes? Thanks Ajay K |
I think you are missing which auth provider to use, auth:jwt or auth:api
you only have auth.
…On Sun, 24 May 2020 at 21:00, ajakl5 ***@***.***> wrote:
Hi Erik Kallen,
I have tried with || and or, for both I get Invalid Expression when I test
from PostMan.
Route.resource('/permissions',
'PermissionController').apiOnly().middleware(['auth', 'is:(administrator or
moderator)'])
Any suggestions with changes?
Thanks
Ajay K
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#22 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAD57ZANCPBD47CBU77AA2LRTFVF3ANCNFSM4FSF6HOQ>
.
|
Now try with or
…On Sun, 24 May 2020 at 21:15, ajakl5 ***@***.***> wrote:
Erik,
I have changed to :
Route.resource('/roles',
'RoleController').apiOnly().middleware(['auth:jwt', 'is:(administrator ||
moderator)'])
, still same issue.
[image: 2020-05-25_003442]
<https://user-images.githubusercontent.com/48468112/82762868-0f897f00-9e21-11ea-873a-ceace2d7a722.png>
Thanks
Ajay K
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#22 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAD57ZA3WLCFPUJZQPJM42DRTFW6XANCNFSM4FSF6HOQ>
.
|
Hi Erik, Yes, it finally works. Thanks Ajay K |
owwwwwwwwww mannn thanks thanks thanks mann ahhhhhhhh!!! saved me a really big time 😆 |
In case anyone is interested in knowing why |
In my application I have added multiple roles such as administrator and I am trying to limit routes to specific roles as shown in the documentation
however only the first role is considered and if I have a support role (in this example) I receive a forbidden error.
Looking at the code in the middleware (src/Middlewares/Is.js)
I looked at the values passed and it seems to me the method does not receive the expected input
Expression [ [ '(administrator ' ] ] (administrator
where to me it looks like the function expects something like 'administrator || support'Looking at the documentation of adonis middleware it seems that the pipe operator is used for passing multiple middlewares
Middleware uses the pipe expression to define props.
this might have recently changed (I see no mention of the pipe syntax in the adonis 3.2 docs)I would like to know if I am missing something obvious if not my guess is that the passing of operators has to be changed to text versions like 'or' and 'and'
The text was updated successfully, but these errors were encountered: