Try setting the loginRedirect to the Controller::referer( ) function i.e. 'loginRedirect' => $this->referer( )
On Jul 12, 6:09 am, pushpa <[email protected]> wrote: > I am having trouble getting the Auth component redirect. > > I have a login form and I want to keep the user on the page he logs in > on. For example, if he is viewing contact us page, I want to keep him > there after logging in.I have made loginaction page as my login page > to validation purpose.Otherwise i can't validate for password blank > field. Here is my user's controller code : > > function beforeFilter(){ > > $this->Auth->allow('register'); > $this->Auth->autoRedirect = false; > parent::beforeFilter(); > > } > > function loginaction(){ > > if($this->data){ > if($this->data['User']['email']=='') > $this->Session->setflash('E-Mail cannot be blank'); > elseif ($this->data['User']['ppassword']=='') > $this->Session->setflash('Password cannot be blank'); > else { > > $this->data['User']['password']=$this->Auth->password($this->data['User']['ppassword']); > > if($this->User->validateUser($this->data)){ > $this->Auth->login($this->data); > $this->redirect($this->Auth->redirect()); > > } } > > and following is my app_controller code: > > function beforeFilter(){ > > $this->Auth->fields = array( > 'username' => 'email', > 'password' => 'password' > ); > $this->Auth->loginAction=array('controller'=>'users', > 'action'=>'loginaction'); > } > > This will redirecting to the page from where user logged out.But i > want redirection should happen to the page from where user clicks the > login button. I am not getting where i am wrong. -- 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
