kaloja
January 10, 2017, 3:40pm
1
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?
kaloja
January 10, 2017, 8:39pm
3
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?
kaloja
January 12, 2017, 9:20pm
6
Yes, I played around with the permission for the editor role. But I’m logged in as admin when I get this problem.
kaloja
January 13, 2017, 12:27pm
7
Still get the same problem when I have removed the roles folder.
Could you please test this on a clean startkit or plainkit?
kaloja
January 13, 2017, 10:45pm
9
I’m using the starterkit, just for testing stuff. The real site will be in another repo. I’ll try it on the plainkit.
kaloja
January 15, 2017, 9:50am
10
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:
No (php) error message but “Du darfst dies nicht tun” if the editor hit “save”.
The changes are saved anyway,
Here is my “roles” snippet:
...
'panel.page.visibility' => function() {
//error_log($this->target()->page()->template());
//error_log( print_r( $this->target(), true ) );
//error_log($this->state());
if($this->target()->page()->template() === 'page') {
return false;
} else {
return true;
}
},
...
I think the “visibility” is a part of the normal save-flow an…
opened 01:30PM - 12 Jan 17 UTC
closed 08:26PM - 02 Jan 18 UTC
bug
https://forum.getkirby.com/t/role-permission-i-e-panel-page-visibility/6230/20
…
Changes are saved to file in spite of the error message, though.
Could you please provide the role / permissions you are using?
kaloja
January 17, 2017, 2:17pm
12
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.