Add proper 404 page.

This commit is contained in:
Sam Greytalon 2023-11-16 08:49:12 -08:00
parent 2926fd52cd
commit 453d6ab787
1 changed files with 12 additions and 0 deletions

View File

@ -120,6 +120,18 @@ helper render_index => sub ($c) {
my $user = $c->req->env->{REMOTE_USER};
my $path = $url->path;
if ( not -d $ROOT_DIRECTORY . $path->to_route ) {
$path->trailing_slash(0);
$path = $path->to_dir;
$url->path($path);
$c->render(template => 'error',
status => '404',
message => 'That file does not exist!');
return 0;
}
if ( not user_has_permission_on_path($user, 'READ', $path) ) {
$c->render(template => 'error',
status => '403',