sylvainjule / kirby-bouncer

Restrict access of a user role to a specific page (and its children) in the panel.
MIT License
61 stars 6 forks source link

Incompatible with 3.6.0 #8

Closed distantnative closed 2 years ago

distantnative commented 3 years ago

Hi Sylvain,

As you can see from he alpha version of 3.6.0 (https://getkirby.com/releases/3.6), we will remove vue-router with this release. Which of course means that your plugin's functionality would be rendered broken.

However, in anticipation we added two hooks

I would believe that with the panel.route:before hook, we could recreate your plugin. Likely even much simpler than the current setup. Let me know your thoughts - happy to collaborate.

namlit4 commented 3 years ago

hi, any news on this issue? would be awesome to have bouncer working with 3.6!

sylvainjule commented 2 years ago

Hi Nico,

Apologies for the delay in addressing this. Thanks a lot for taking the time to identify the issue and pointing me in those directions! This sounds great and I also feel that it will allow to come up with a much simpler setup.

Although for now, I don't get how to trigger a redirect from the hook. As a first test, I've tried using Panel::go('...') but without success:

'hooks' => [
    'panel.route:before' => function($route, $path, $method) {
        if($path != 'pages/annotator') {
            Panel::go('pages/annotator');
        }
    }
]

Ends up with an error on click anywhere when I'm already on this page (popup shows: "The $view could not be loaded"), and this screen anytime else:

Capture d’écran 2021-11-24 à 16 07 40

As a comparison, it redirects with the simple go('panel/...'), but of course without the proper routing stuff / language code / etc that should happen.

Am I overlooking something? I've just started to dig into this so I might be missing something obvious, I'll keep looking but in the meantime if you have any advice, I'd gladly take them :)

distantnative commented 2 years ago

Indeed, I think we would need to move this https://github.com/getkirby/kirby/blob/main/src/Panel/Panel.php#L305-L312 inside the try-catch block that follows. Could you try if that would work for you?

sylvainjule commented 2 years ago

Awesome, it does!

distantnative commented 2 years ago

Let's see if we can get it in 3.6.1 https://github.com/getkirby/kirby/pull/3964

sylvainjule commented 2 years ago

Awesome! I'll get working on the plugin based on this.

sylvainjule commented 2 years ago

Seems like it's good to go on the next branch, when 3.6.1 rolls out :)

distantnative commented 2 years ago

Awesome