Tuesday, December 28, 2010

Help with function Login()--using Auth (Redirecting issue)

Users_controllers.php:
~~~~

var $name = 'Users';

/*some codes in between*/

function login()
{
if(!empty($this->data))
{
// If the username/password match
if($this->Auth->login($this->data))
{
$this->redirect(array('action' => 'index'), null,
true);
} else {
$this->User->invalidate('username', 'Username and password
combination is incorrect!');
}
}
}

-----------------
Hi,

After successful login, I want it to redirect to app/views/posts/
index.ctp

Originally, the redirect code is like this:
(1)
~~
$this->redirect('/');
~~
I changed to:
(2)
~~
$this->redirect(array('action' => 'index'), null, true);
~~
(3)
~~
$this->redirect(array('action' => 'views/posts/index'), null, true);
~~

All failed to redirect to *app/views/posts/index.ctp
~~
It consistently redirected me to my App/index.ctp which displays all
my cakephp versions stuff (mod rewrite...etc the green page),
regardless of the 3 redirect methods used above.

Is it something wrong with my Login() function instead ??

Thanks,

Maxim J.

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: