I am a newbie to PHP/Kohana application development.
In the web app i am developing , whenever a new request come to the controller i am required to check if the user is logged-in or is he having sufficient privileges to commit the action he requested. Since my application have different category of members(having different degree of authority), every controller method ends up having multitude of if/else branches. the code is repeated in other controller methods as well.
Is there any suggested way to centralize these calls and to avoid code repetition? I mean is the only way to achieve this by writing a method to encompass all the user session code ? or am i missing any functionality that is baked into the PHP/Kohana which is already dealing this scenario?
eg:-
if (Auth::instance()->logged_in('commentator')) {
// do something here.
}
else if (Auth:instance()->logged_in('admin')){
// do something here.
}
else if (Auth:instance()->logged_in('reviewer')){
// do something here.
}