Redirect with field does not work with modules blueprint set to hide: true

Redirect with a field only works if you have set the modules blueprint to hide: false. If I use hide: true in the blueprint I get an error from this code snippet:

if($page->ui()->read() === false) {
  throw new PermissionsException();
}

The snippet is in kirby/panel/app/controllers/pages.php

The outputted error message in the debugger is:

Kirby \ Panel \ Exceptions \ PermissionsException
You are not allowed to do this

Do you have a solution for this or are you using hide: false?

Uh strange. It’s working with hide: false and hide: true for me.

I just saw that i wrote to put the file in site/fields/redirect.php.
Actually it must be site/fields/redirect/redirect.php. but that should not trigger a permission exception. What Kirby version are you using? And what does your blueprint look like?

Yes, I noticed that. I added the folder redirect to get it work. I’m using Kirby version 2.4.1.

in site/blueprints/modules.yml

title: Moduler
hide: true
pages:
  template:
    - module.text
    - module.gallery
fields:
  title:
    label: Title
    type: text
  modules:
    label: Moduler
    type: modules
  redirect:
    label: Redirect
    type: redirect

in site/blueprints/default.yml

title: Default
pages:
  template: default
  build:
    - title: Moduler
      uid: modules
      template: modules
fields:
  title:
    label: Title
    type: text
  modules:
    label: Moduler
    type: modules

Sorry i can’t reproduce this.
We should move this in a seperate topic or perhaps @texnixe could split this one up?

Do you have any custom permissions set up in your project?

Yes, I played around with the permission for the editor role. But I’m logged in as admin when I get this problem.

Still get the same problem when I have removed the roles folder.

Could you please test this on a clean startkit or plainkit?

I’m using the starterkit, just for testing stuff. The real site will be in another repo. I’ll try it on the plainkit.

With a clean plainkit it works very well with hide: true.

There is obviously something wrong with the custom permissions.
Perhaps it has something to do with:

https://github.com/getkirby/panel/issues/989

Could you please provide the role / permissions you are using?

Here is the role file I was testing with:

<?php

// site/roles/editor.php
return [
  'name'        => 'Editor',
  'default'     => false,
  'permissions' => [
    '*'                 	   => true,
    'panel.site.update' 	   => false,
    'panel.page.create' 	   => false,
    'panel.page.update' 	   => false,
    'panel.page.delete' 	   => false,
    'panel.page.visibility'        => false,
    'panel.user.*'      	   => false,
    'panel.user.read'   	   => true,
    'panel.user.update' 	   => function() {

      if($this->user()->is($this->target()->user())) {
        // users are allowed to edit their own information
        return true;
      } else {
        // other users can't be edited
        return false;
      }

    }
  ]
];

I get the error even without the custom permissions set.

Sorry I have no idea what is going on there.