Based on this, I am trying to restrict access to certain APIs based on admin role.
If I provide invalid access_token, the API returns 401 - Not authenticated (Working fine)
If I provide a valid admin user access_token, API returns the expected JSON output. (Working as expected)
However, if I provide a valid non-admin user access_token, API returns the following output.
[error] #PID<0.2419.0> running MyAppWeb.Endpoint (connection #PID<0.2418.0>, stream id 1) terminated Server: localhost:4000 (http) Request: GET /api/v1/customers ** (exit) an exception was raised: ** (ArgumentError) flash not fetched, call fetch_flash/2
What is this error due to and how do I gracefully return a proper error code and error message when non-admin access_token is provided for the API?