Wednesday, December 29, 2010

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

Hi cricket ! you're awesome, thanks your working and explanation
solved the puzzle I had..

Amit, I will check that link out..thanks too.

Regards,
Maxim


On Dec 30, 12:54 pm, Amit Badkas <amit.sanis...@gmail.com> wrote:
> Hi,
>
> By default, Auth component redirects to referrer page (if set) otherwise to
> the page set in loginRedirect. So you may need to overwrite
> 'Auth.redirect' session
> parameter.
>
> FYI, please have a look athttp://book.cakephp.org/view/1270/loginRedirect
>
> Amit Badkas
>
> PHP Applications for E-Biz:http://www.sanisoft.com
>
> On Thu, Dec 30, 2010 at 12:29 AM, cricket <zijn.digi...@gmail.com> wrote:
> > On Tue, Dec 28, 2010 at 11:58 PM, John Maxim <goog...@gmail.com> wrote:
> > > 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!');
> > >                 }
> > >         }
> > >  }
>
> > The code in your login method does basically what Auth would do if
> > left to its own devices. You could get the same functionality as above
> > by setting the following in AppController's beforeFilter method:
>
> > // this tells Auth to handle redirects
> > $this->Auth->autoRedirect = true;
>
> > // this tells Auth where to send the user
> > $this->Auth->loginRedirect = array(
> >        'controller' => 'posts',
> >        'action' => 'index'
> > );
>
> > $this->Auth->loginError = 'Username and password combination is
> > incorrect!';
>
> > if (!$this->Session->read('Auth.User'))
> > {
> >        $this->Auth->authError = 'Please log in';
> > }
>
> > You set the first one to false when you need to do some routines
> > during login--like record the login time, set a session var, etc.
> > Otherwise, you can leave login() empty and allow Auth to sort it all
> > out.
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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<cake-php%2Bunsubscribe@googlegroups.com>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

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: