Seems pretty correct to me. Here's a piece of logic to determine if a user
is visiting an admin page and if they're an actual admin. It's in the
app_controller file.

public function beforeFilter ()
{
    parent::beforeFilter();
    $this->isAdmin = $this->Session->read('isAdmin');

    if (isset ($this->params['admin']) && $this->params['admin'] &&
!$this->isAdmin) {
        $this->redirect('/');
    }
}

I know this isn't exactly what you're doing... but you could have something
similar to detect a logged in user and what their user type is, and then
redirect them accordingly. I think your logic is sound though. Others can
set me straight if I'm also off... =D

Happy coding,

~Philip


On Tue, Jun 14, 2011 at 9:23 AM, chris <[email protected]>wrote:

> Just wanted to know what the best way is to acheive what I am doing.
>
> My requirement, to show a different home page to the user dependant on
> 2 things.
>
> 1) If they are logged in
> 2) What 'user level' they are (A custom variable in my users table,
> which I use to identify different user types)
>
> From looking around, I've created a 'myindex' controller, which one
> action 'index'. Then I set the route as follows:-
>
> Router::connect('/', array('controller' => 'myindex', 'action' =>
> 'index'));
> replacing the previous
> Router::connect('/', array('controller' => 'pages', 'action' =>
> 'display', 'home'));
>
> then the index action is something like
>
> if($this->Auth->User('accounttype_id')==ACCOUNTTYPE_ADMIN)
>        $this-
> >redirect(array('controller'=>'dashboard','action'=>'index','admin'=>1));
>
> etc..
>
> with a default for not logged in users of
>
> $this-
> >redirect(array('controller'=>'pages','action'=>'display','home'));
>
> but then I wanted the default home page url to be just www.mydomain.com
>
> So I created myindex/index.ctp and put the static HTML from pages/
> home.ctp into this.
>
> This all seems to work, but I just wanted to know if there are better
> ways to handle this?
>
>
-- 
http://lonestarlightandsound.com/

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to