Hi,
I'm using pagefileSecure to protect a template (and specifically its files) from public access.
Now I want to allow specific users to view their own files. I already tried hooking Page::viewable, but the template of the page (where the file is stored) doesn't even show up when I dump every hook.
I have this code in site/ready.php
$wire->addHook('Page::viewable', function (\ProcessWire\HookEvent $event) {
bd($event->object->template->name); //my-template doesn't even show up here
switch ($event->object->template->name) {
case "my-template":
$event->return = true; // the user still gets a 404 when attempting to access the file on frontend.
break;
default:
break;
}
});
What would be the best way to allow access to specific files for individual users, even when they don't have a role that can view the page?