-
Notifications
You must be signed in to change notification settings - Fork 18
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
Custom actions - ex : can('createMainAccount', 'accounts') #21
Comments
Hey :) How do you want to check them? On the client side or on the server side? |
Hey ! on the server side So if user |
It would be something like |
My Accounts service is something like this
and i would like to check if user can do this. I was thinking about changing the method in the context so that authorize() as Edit: |
|
Okay but on the client i'm doing :
Then server side my class is
and i want user with role role is for
but it should be okay if and
tell me if i'm not clear. Thanks a lot for your help and this awesome package btw ;) |
Did you see the getting started guide: https://feathers-casl.netlify.app/getting-started.html#define-static-rules ? If you follow this there, you can see how to define rules for multiple users depending on roles. |
Yes i followed it and i have some rules like this
and this is working. but where i don't get it it's about this if i do this |
Have you tried this?
|
it ensures that |
Okaaay got it !! So to let all users create accounts and only user.role = 'user' cannot createMainAccount i should do : ?
|
I would like to do the same with PUT / PATCH. and i added a but it's always forbidden... if i remove Thanks a lot for your time. |
yep, I think this should work. Is it the typo: 'refreshToken' vs 'refreshTokens' ? The action pattern is somewhat weird. On patch/update So I'm afraid it's not possible the way you want to use it, because its logic is bound to the data layer. |
Yes, it's a typo !
Okay got it !
Okay i see. but i can't expose custom methods to the client rights ? Client side i can't do So i should create an other service and use POST with data.action : 'refreshTokens' ? Thanks a lot. |
You can pass rules to the client. It's described in the docs. I use it for As of now, feathers does not support custom methods, but it will in v5. See the ongoing PR over there. feathers-casl then will add support for custom methods as well (see #22 - thanks for the idea ;) ). In my opinion you maybe want to have a service that's called "refreshTokens" with |
Closing this as of now. If there's anything else I can do, let me know. |
Thanks a lot for your help on this @fratzinger . I created a new service for handling these special cases. |
Hi.
Is it possible to define custom action like this
can('createMainAccount', 'accounts')
?How to check if it's authorize with feathers-casl ?
From the website it seems possible : "Define permissions not based on methods: can('view', 'Settings')"
My use-case :
I would like to pass action with
data.action : createMainAccount
from the client and check if user can on the server.So i can do POST on accounts with
data.action : createMainAccount
Thanks
The text was updated successfully, but these errors were encountered: