سؤال

If a module requires a claim, and the user does not have the claim a 403 response is returned. eg:

this.RequiresClaims(new[] { "SuperSecure" });

or

this.RequiresValidatedClaims(c => c.Contains("SuperSecure"));

but that just returns a blank page to the user.

How do I deal with a user not having the required claim? Can I 'catch' the 403 and redirect?

The RequiresClaims method returns void or uses the pre-request hook to throw back a HttpStatusCode.Forbidden. What should I do so the user knows what has happened?

Many Thanks, Neil

هل كانت مفيدة؟

المحلول

You can catch it either by writing your own post request hook (either at the app level, or the module level) or by implementing your own IErrorHandler, probably wrapping the default one.

The error handler stuff is going to change so you will be able to register multiple ones (for different error codes), it's setup to do that (with the "can/do" interface) but for some reason my brain didn't add it as a collection :-)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top