Custom blueprints per user role plugin causes 504 Timeout

Hello there,
often times I create Kirby projects with user roles that have different permissions and blueprints in mind.
An admin can create pages and assign them to users with the role ‘editor’. The editor can only see and edit the pages that are assigned to them in the panel, nothing else.
I use these proposed solutions for that:

User blueprints and panel permissions
User permisions for specific page and it’s subpages

It all seems to work fine, but some clients tell me that their site is unresponsive from time to time. Because there was never an error thrown, i nearly went crazy searching for the solution, because i dont know how to debug such a thing in php.

Today, i think i found the cause in the custom plugin i use

<?php
if(($user = kirby()->user()) && $user->role() == 'diver') {
    $dir = __DIR__. '/blueprints/editor/';
} else {
    $dir = __DIR__ . '/blueprints/admin/';
}
Kirby::plugin('dodo/user-roles', [
   $kirby = new Kirby([
       'roots' => [
           'blueprints' => $dir,
       ],
   ])
]);

Screenshot 2021-02-03 183801

With the plugin installed, as a user tries to logout of the Panel, the menubar disappears and everything freezes. Sometimes it doesnt even work to go back to the homepage and a 504 Gateway-Timeout error is thrown.

For testing purposes i set up a fresh starterkit installation with just the user-role plugin installed. Same problem.
https://userroles.4lima.de/
panel access:
user: admin@user.de
pass: 12345678

If someone could point me in the right direction, it would be highly appreciated.

Kind regards,
Dodo

I can reproduce this, but I don’t think it works to register all blueprints like this, the examples with the plugin all only register single blueprint files.

If you want to provide completely different blueprint sets, you should do this in index.php, see cookbook:

1 Like

Thank you very much for that fast reply, now everything runs significantly faster!
I think I just got confused and assumed in the other threads that it is a better practice to put such things into a plugin, not knowing that the design of the solutions is vastly different.