What I did was simply write my own 

Configure::write('Routing.CustomRouting', array('Admin' => 'admin', 'Owner'
=> 'manage' , 'Employee' => 'editor')); 
simply because my routes and Roles did not match up and I hate arrays that
are 0,1,2 since that's means nothing. Imagine trying to remember if
$something[0] = $something thru the site....forget that!

Then in isAuthorized function since everyone is routed thru their own prefix
simply compare the prefix (manage/profile would mean Owner role) with the
value.

function isAuthorized() {
        $access = false;

if ( isset ( $this->params['prefix'] ) ) {
        $routes = Configure::read('Routing.CustomRouting');
        $access_role = $this->Auth->User( 'role_id' );
        $routed_role = $routes[$access_role];
        $this_prefix = $this->params['prefix'];

if( $this->Session->valid() && $this_prefix === $routed_role ) {

//do other stuff define layouts whatever

$access = true; 
}

Return $access;

}


That worked for me. Every situation is different so it might help or get you
started.

Dave



 
-----Original Message-----
From: chris [mailto:[email protected]] 
Sent: December-14-10 7:32 AM
To: CakePHP
Subject: Prefix routing and different user types

Hi

I have an application that a user can login too to access certain
parts of the site.

I'm using the Auth component, and have added a variable to my database
that has different user types.

I am then using the admin prefix routing, as well as another customer
prefix for one of the user types. So I have views such as

/usertype/model/add
/admin/model/add

etc

What I want to know is what is the best way to automatically route
people through to these, dependant on their user type?

One thing I want to do is automatically force the user into a route at
the login stage. I currently define this using

$this->Auth->loginAction =

Is there a way to define different ones dependant on my user types?

Thanks

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups
"CakePHP" 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?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en

Reply via email to