Monday, August 31, 2009

Re: change route after authroize users

oh, I get what you mean. You want to display different content for loggen in and guest users.

You know, it's so hard to do that, but the key to cakePHP is that you actually need to think simple. I mean not programmer's simple, but - simple.

What I did is I used a different layout! Sounds crazy, but is so simple and works like a charm, trust me! What you do is create a
beforeFilter(){
    parent::beforeFilter();
    if ($this->Auth->user('role') == 'member'){
        $this->layout = 'loggedin';
    }
}

in controllers you require a diff content. In the different layout serve different elements and they'll do the job for you also (Y).

Let me know if you find this handy,
Faifas
http://voveris.eu/


On Mon, Aug 31, 2009 at 17:53, AgBorkowski <andrzejborkowski@gmail.com> wrote:

i know that but i want change general route '/' so yes your trick
witch redirect working after user did login but after even go to /
load default general route from /

but i'll try user Route::conntect in login() :)

On 31 Sie, 10:32, Aivaras <faifas1...@gmail.com> wrote:
> Hey,
>
> did you take a look at thishttp://book.cakephp.org/view/391/loginAction?
>
> Faifas
>
> On Mon, Aug 31, 2009 at 11:05, andrzejborkow...@gmail.com <
>
>
>
> andrzejborkow...@gmail.com> wrote:
>
> > i want to change default route after login my users, i try like this:
>
> > [/project/app_controller.php]
> > public function beforeFilter() {
> > (...)
> >        if($this->Auth->user()){
> >                Router::connect('/', array('controller' => 'users', 'action'
> > => 'profile'));
> >                Router::promote();
> > }
>
> > but it dont work and still active first default route form route.php..



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: