Thursday, May 29, 2014

redirect not working

Hi,
I am following this tutorial below and I dont get an error but what happens is that when i login
I get redirected to the wrong place, explained below

cakephp/posts/index   -correct and I get redirected here sometimes
cakephp/   - other times I get redirected here with same login name

 
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html


class AppController extends Controller {
   
 public $components = array(
    'Session',
    'Auth' => array(
        'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
        'logoutRedirect' => array(
            'controller' => 'pages',
            'action' => 'display',
            'home'
        ),
        'authorize' => array('Controller') // Added this line
    )
);
///
class UsersController extends AppController
{
public function login() {
    if ($this->request->is('post')) {
        if ($this->Auth->login()) {
            return $this->redirect($this->Auth->redirect());
        }
        $this->Session->setFlash(__('Invalid username or password, try again'));
    }
}



Connect with us: 

    

Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the "Communication") is, unless otherwise stated, confidential,  may contain copyright material and is for the use only of the intended recipient. If you receive the Communication in error, please notify the sender immediately by return e-mail, delete the Communication and the return e-mail, and do not read, copy, retransmit or otherwise deal with it. Any views expressed in the Communication are those of the individual sender only, unless expressly stated to be those of National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any of its related entities. NTSP does not accept liability in connection with the integrity of or errors in the Communication, computer virus, data corruption, interference or delay arising from or in respect of the Communication.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: