After reading documentation, it seems I should be able to do this from my controller methods.
// If user is not authorized to perform this action:
throw new ninja.exceptions.BadRequestException("You do not have permission to delete this record.");
I would have expected this to return the "views/system/403forbidden.ftl.html" template.
<#import "../layout/defaultLayout.ftl.html" as layout>
<@layout.myLayout "Error. Forbidden.">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="error-template">
<h1>
Oops!</h1>
<h2>
403 Forbidden</h2>
<div class="error-details">
Sorry, an error has occured. Requested page is forbidden!
</div>
</div>
</div>
</div>
</div>
</@layout.myLayout>
The actual page being returned is:
Oops. That's a bad request and all we know.
How can I get it to actually use the template for the 403 Forbidden result? And, is there a way in that template to display the message contained in the exception? I would like to show "You do not have permission to delete this record.", or whatever message we include from the controller.