Miss understanding to use policy in read action, Handling Missing Actor
Hi sorry again, I've read the documentation multiple times but still struggle to properly handle a case in my
:me
action.
Here’s my current setup:
This works when a valid token (and therefore actor) is present. However, when I make a JSON API request without a token, I receive a generic 400 error like:
I want it to return a 403 Forbidden instead. So I tried this policy:
Now, when there’s no token, it correctly returns 403 Forbidden.
But unfortunately, when there is a token, I get a 404 Not Found instead:
Even when I adjusted the code further, I still get 404.
How can I ensure:
* 403 Forbidden is returned when no token is provided
* 200 OK (with user info) is returned when a valid token exists
instead of getting a 404?
By the way, my user is using multitenancy global? true
I think i miss a part 😢🤔
Thank you in advanceSolution:Jump to solution
Oh i changed my order of policies it shows :thinkies: 🥲
this was the last line of policies and i move
```elixir
bypass always() do...
2 Replies
Solution
Oh i changed my order of policies it shows :thinkies: 🥲
this was the last line of policies and i move
and i move top of
And for preventing warning of no actor
:thinkies:
it is about lack of my understanding about policies!! i move order of it and it fixed for now
And other thing i understood, none generic action has some default behaviour some times make problem especially in my case with multi tendency
so i think some times generic one can be better, it can bypass it