Jump to content

Allowing access to a file on a page the user can't view


clemens
 Share

Recommended Posts

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?

Link to comment
Share on other sites

That doesn't seem to change anything. The main issue imo is the fact that the page template in question doesn't even show when I dump every successful hook.

I'm mostly surprised that I can't find any previous solutions to this issue.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...