Hello!
I want that a route in my plugin only works for authenticated users in /panel/site/something. How does this work? 'filter' => array('auth')
doesn’t do the trick…
EDIT:
Sorry, it does work in the meaning of that I will be redirected to the login page, but the action function that is added to this route will be executed first!!
What sort of route is that? What is your context? For api
routes, the user must be authenticated anyway… for everything else, you can simply check if you have a kirby user (with a certain role)
I think that’s an old Kirby 2 property not available in K3 anymore.
Uff okay… Got it finally working by checking within the action itself:
[
'pattern' => '(?:(:any)//?)?mysite',
'action' => function() {
if (kirby()->user()) {
Db::update(here is my code);
}
},
'method' => 'GET'
]
Well, ideally I wanted to have it within a /panel/ route, but that didn’t work so I had to move it to (?:(:any)//?)?hereismyroute