Is there a way to edit the default error return by Strapi for permission / token error?
For example, in roles & permissions under Public role, I uncheck the route for send-email-confirmation
. If I use postman and try doing localhost:1337/auth/send-email-confirmation
, I would get such error return
{
"statusCode": 403,
"error": "Forbidden",
"message": "Forbidden"
}
I believe this is the default middleware / policy
I know where I can get the default send-email-confirmation
controller and edit it, but that is only if Roles & Permissions
are enabled / checked inside public role.
Same as if a route requires headers
of Authorization
token but if it is not provided, a default error will be given again which I am not able to find where to customize it.
I don't seem to find it inside strapi documentation or maybe I am using the wrong key words to search.
Thanks in advance for any suggestions + advices.
auth token - permissions validation and errors are managed in this file - https://github.com/strapi/strapi/blob/0c6d39297f6f8a4f983e22fb48256b42da2a8605/packages/strapi-plugin-users-permissions/config/policies/permissions.js#L15
If you want to update this file, you will have to follow the customization concept - https://strapi.io/documentation/3.0.0-beta.x/concepts/customization.html#plugin-extensions
With this, you will be able to change the error message.