Denying Requests
Latch includes lib/pages/denied.php for rendering 4xx responses.
Example:
<?php
if (!Latch\Session\has_permission("Edit App"))
{
$content = <<<HTML
<p>You do not have permission to edit this user's profile.</p>
HTML;
Latch\File\ext_part_include(part: "pages/denied.php", args: [
"content" => $content,
"status_code" => 403,
]);
exit;
}
In this example, Latch checks whether the current session has the Edit App permission. If it does not, the denied template renders a 403 response and the active script exits.
The template accepts these arguments:
content: HTML string to include in the body of the page. By default, the template uses a generic message for the given status code.status_code: Integer response code. Common values are401unauthorized,403forbidden, and404not found.status_text: Short explanation for the response code, used in the page title.
This template inherits lib/pages/basic.php, which includes the normal header and footer templates for a complete page.
