Monday, March 1, 2010

Re: Login Redirects

Hi I did this to solve thart situation, I am not sure if that is the
best way to do that.

In my controllet I leave the login function as this :

function login() {
}

In app_controller.php, I created a beforeFilter function as this :
function beforeFilter() {
$this->Auth->loginRedirect = array('controller' => 'users',
'action' => 'index');
$this->Auth->logoutRedirect = '/';
$this->Auth->authorize = 'controller';
$this->Auth->userScope = array('User.status_id' => '1');
$this->set('loggedIn',$this->Auth->user('id'));
}

So that way login redirects to what I want.

I hope this can help you :D

On Mar 1, 5:58 pm, JoHN <laojoh...@gmail.com> wrote:
> Hi..
>
> I have currently set autoRedirect to false in app_controller ($this->Auth->autoRedirect = false;).. and made a redirection upon logging
>
> in..
>
> here the codes for login function:
>
> Function login() {
>
> if ($this->Session->read('Auth.User')) {
>                 $this->Session->setFlash('You are logged in!');
>                 $this->redirect('/announcements/home', null, false);
>         }
>
> }
>
> When the user logs in, it redirects to announcements/home instead of
> the last page where he was when he last logged out.. the problem is,
> that the page doesn't seem to update and would still seem like the
> user has not logged in until the user refresh the page. the
> controlpanel will not appear as it supposed to.
>
> how can i solve this problem?
>
> been stuck in this situation for more than 5 hours now. :(
>
> 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 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: