The general way that I am doing this is in my AppController I execute the beforeFilter = 'checkAccess';
In my checkAccess function I first check a variable called $this->authorized for being null. If it is set to null I assume everyone has access.
Otherwise I have the specific roles defined in an array in the $this->authorized variable that have access.
So pseudocode is....
class AppController extends Controller
{
var $beforeFilter = 'checkAccess';
var $authorized = null;
function checkAccess() {
if($this->authorized == null) return true;
//check to see if your logged in user's role is in the authorized array
//if it is return true, if not redirect to login page, or if already logged in return false.
}
}
{
var $beforeFilter = 'checkAccess';
var $authorized = null;
function checkAccess() {
if($this->authorized == null) return true;
//check to see if your logged in user's role is in the authorized array
//if it is return true, if not redirect to login page, or if already logged in return false.
}
}
So in a controller that I want everyone to be able to access I can just not define the authorized array (it is set to null be default above).
In a controller I want to restrict access to I would set it to an array of roles that get access.
My setup is a bit more complicated than this, but that is the general idea.
On 7/14/06, Luke <[EMAIL PROTECTED]
> wrote:
Anybody have an answer for this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---
- Re: Setting a variable throughout cake when user lo... Luke
- Re: Setting a variable throughout cake when us... John Zimmerman [gmail]
