`relate_actor allow_nil? false` returning 400 error when `authorize_if actor_present()`
Hi friends, I have a question about
change relate_actor. see my code, when i use default relate_actor which is allow_nil?: false, i get 400 error when i do not send user token or actor, for example without auth i send request
But with these policies i expected to return 403 error
So i am force to use change relate_actor(:follower_user, allow_nil?: true) , with allow_nil?: true it returns forbidden error instead of 400.
Why it has this behaviour? am i forgetting the policy concept again 😱
Thank you in advance7 Replies
change relate_actor(:actor, allow_nil?: true) IIRCyes i did and it works! but is there any reason?
AI says:
The issue is that relate_actor is checking for the actor in the context, not checking the data being created.
relate_actor relates the current user to the record being created/updatedSorry to waste your time, I am confused and still do not understand why the policy let it go to
change and do not return error immediately!! when authorize_if actor_present() not passed
i just read this code too
https://github.com/ash-project/ash/blob/6d21033ec799f7ebce0c9e8b36beb1583e77b63b/lib/ash/resource/change/relate_actor.ex#L55-L66
Changes are run before policies
But not the books added by the changes
This Discord has not any option to bookmark or pin it 🥲 , it is very important . i think it is not in policy doc https://hexdocs.pm/ash/policies.html
Thank you
Sorry again 🙏 , i think
filter expr in like changes run before policies in read?
like this return 400
is there better and short way to get 403 instead of this code?
Ah...that's interesting. No that is the only way. Although your second clause there should be
filter(false)