How do I make a query require authentication and return an error if the user is not logged in?
Currently, the query returns nothing when there is no user logged in. But I would like it to return an authentication error.
4 Replies
you might be looking for the
access_type
option on a policy - for a read action, if the policy fails it will return an unauthorized error instead of applying a filterChanging this option to
:strict
causes the query to return a forbidden
error 🤔. I wish it were unauthenticated
, but this is already better than how it was before.ah forbidden not unauthorized, my bad
making it
unauthenticated
could be hard to do, given a policy can have anything in it, not just verifying that an actor is presentWe don't support custom error messages from policies yet
I'd like to though
You could add a change or preparation to your action and add a custom error
Instead of using policies