Hi,
I am trying to use the f3-access library and I am getting some weird results with it.
I have a controller class that is being extended by all my other controllers (1 controller to rule them all).
In this controller I have the following code:
function beforeroute() {
$access=Access::instance();
$access->policy('allow'); // allow access to all routes by default
$access->deny('/admin*');
// admin routes
$access->allow('/admin*','100'); //100 = admin ; 10 = superuser ; 1 = user
$access->deny('/user*');
// user login routes
$access->allow('/user*','100'); //100 = admin ; 10 = superuser ; 1 = user
$access->allow('/user*','10'); //100 = admin ; 10 = superuser ; 1 = user
$access->allow('/user*','1'); //100 = admin ; 10 = superuser ; 1 = user
$access->authorize($this->f3->get('SESSION.user_type'));
$layout=new LayoutController();
$this->f3->set('layout.side_menu',$layout->LayoutMenus());
}
I think this is self-explanatory: all visitors can access everything, then admin routes are denied to anyone without admin access (session.user_type=100),
Then user routes are denied accepted for logged in users (user_type=1). Super users are not really used for now.
Is this the correct way to handle this?
It seems to be working quite well but the issue I am running into is that on a page refresh with ctrl+f5 this will sometimes return a 403 (never on f5 refresh though). This happens on the index page which should always be accessible to anyone.
Sometimes it happens every other time, at other times I need to refresh with ctrl+f5 at least 5 times before the 403 is returned. This happens wether a user is logged in or not.
I am using cache, could this be interfering with this?
Sometimes after trying to figure this out and changing caching options and access options the problem will not pop up at all, so it is hard to reproduce at times, but when it starts occuring it seems to be occuring often.