Tuesday, April 24, 2012

Re: Too many redirects when login-user access the control they don't allow to go

The login method is special and shouldn't be included in allow().

On Tue, Apr 24, 2012 at 4:22 PM, Budd <buddfung@gmail.com> wrote:
> public function login() {
>     if ($this->request->is('post')) {
>         if ($this->Auth->login()) {
>             $this->Session->setFlash(__('Login Success'));
>             $this->redirect($this->Auth->redirect());
>         } else {
>             $this->Session->setFlash(__('Invalid username or password,
> try again'));
>         }
>     }
> }
>
>
> If no login, nobody can access login page, no?
>
>
>
> On Apr 24, 2:57 pm, lowpass <zijn.digi...@gmail.com> wrote:
>> > $this->Auth->allow(array('login','logout'));
>>
>> Don't include login here.
>>
>> Also, do you have a login() method? If so, post that.
>>
>>
>>
>>
>>
>>
>>
>> On Tue, Apr 24, 2012 at 10:52 AM, Budd <buddf...@gmail.com> wrote:
>> > Hi,
>>
>> > I have setup ACL component and everything looks fine. But only one
>> > problem.
>>
>> > If i am not login and access some permission denied page, it will
>> > redirect me to login page
>>
>> > If i am login to basic user and access some permission denied page, it
>> > will show up the error page "Too many redirects".
>>
>> > I don't know which path it was point to and keep looping, any way to
>> > show it?
>>
>> > I added this to my app controller
>>
>> >        $this->Auth->loginError = "Wrong credentials. Please provide a
>> > valid username and password.";
>> >        $this->Auth->authError = "You don't have sufficient privilege
>> > to access this resource.";
>> >        $this->Auth->loginAction = array('controller' => 'users',
>> > 'action' => 'login');
>> >        $this->Auth->logoutRedirect = array('controller' => 'users',
>> > 'action' => 'login');
>> >        $this->Auth->loginRedirect = array('controller' =>
>> > 'adcontents', 'action' => 'index');
>>
>> > The users controller i added:
>> > function beforeFilter() {
>> >    parent::beforeFilter();
>> >    $this->Auth->allow(array('login','logout'));
>> > }
>>
>> > I don't know how i can fix this problem as i didn't redirect to
>> > somewhere else. It is only happen when i login to basic user not
>> > public user.
>>
>> > I already spent couple of hours to figure it out. But i have still no
>> > cue
>>
>> > Thank you.
>>
>> > --
>> > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
>> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions.
>>
>> > To unsubscribe from this group, send email to
>> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php
>
> --
> 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
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate