I have an Umbraco 7 site that makes heavy use of custom API endpoints, some of these are protected to only allow members through.
I've hit a slight problem when this happens as we display the error that gets returned, Authorization denied for this request.
Obviously this isn't very user-friendly so I was wondering if there is a way to change or server a different message. For example, if the member hits the endpoint while logged out, it returns a more friendly message of You have been logged out, please log back in and try again, or similar.
An example of how my method is set up:
[HttpPost]
[AcceptVerbs("POST")]
[Umbraco.Web.WebApi.MemberAuthorize(AllowType = "member")]
public HttpResponseMessage Add(AddCommentSubmission submission) {}
If this isn't possible using the middleware, my next option would be to catch the forbidden request in JavaScript but I'd like to keep all errors returning as-is from the api.
Changing the Error when using MemberAuthorize
Hi,
I have an Umbraco 7 site that makes heavy use of custom API endpoints, some of these are protected to only allow members through.
I've hit a slight problem when this happens as we display the error that gets returned,
Authorization denied for this request
.Obviously this isn't very user-friendly so I was wondering if there is a way to change or server a different message. For example, if the member hits the endpoint while logged out, it returns a more friendly message of
You have been logged out, please log back in and try again
, or similar.An example of how my method is set up:
If this isn't possible using the middleware, my next option would be to catch the forbidden request in JavaScript but I'd like to keep all errors returning as-is from the api.
Thanks,
Ben
is working on a reply...