OK, I now seem to have success by destroying all session data in login 
function _before_ logging in (shown below).
Am I violating any cakePHP conventions in doing so?
Or perhaps simply clearing some default setting that I have been 
overlooking so far?

Thanx, McS

Server Software Apache/2.2.22 (Win32) PHP/5.4.14
CAKE_VERSION     2.3.4

UsersController.php:
    public function login() {
        $this->Session->destroy(); // attempt to clear session data before 
login
        if ($this->request->is('post')) {
            if ($this->Auth->login()) {
                return $this->redirect($this->Auth->redirectUrl()); // from 
Auth tutorial
            } else {
                $this->Session->setFlash('Your username or password was 
incorrect.');
            }
        }
    } // end login()

On Wednesday, May 8, 2013 12:27:14 PM UTC-4, McScreech wrote:
>
>
> Been following the acl and auth tutorials and appear to be near working 
> except for AuthComponent loginRedirect and logoutRedirect properties. Very 
> bare-bones setup as listed below.
>
> Watching the DebugKit.Toolbar output I note the following:
> 1) on the users/login page Session > Auth > redirect is /pages/home, no 
> user defined
> 2) form accepts username and password provided and redirects to 
> /pages/home, Session > Auth > user and activeUser are defined correctly
> 3) also clicking the users/logout link on that page redirects to 
> /users/login page with same conditions as 1)
>
> But I expected my setup below to assign the loginRedirect to /lots/index 
> and logoutRedirect to /pages/home? What did I miss?
>
> MTIA, McS
>
> Server Software Apache/2.2.22 (Win32) PHP/5.4.14
> CAKE_VERSION     2.3.4
>
> <?php
> Controller/AppController.php:
>     public $components = array('DebugKit.Toolbar', 'Session', 'Acl',
>         'Auth' => array(
>             'authorize'            => array('Actions' => 
> array('actionPath' => 'controllers'),
>                                          'Controller' => 
> array('actionPath' => 'controllers')),
>             'loginAction'        => array('controller' => 'users', 
> 'action' => 'login'),
>             'loginRedirect'        => array('controller' => 'lots', 
> 'action' => 'index'),
>             'logoutRedirect'    => array('controller' => 'pages', 'action' 
> => 'home')
>         )
>     );
>
>     public $helpers = array('Html', 'Form', 'Session');
>
>     public function beforeFilter() {
>         // Configure AuthComponent
>         $this->Auth->allow('login', 'logout', 'display', 'search');
>
>         // Remember user who is logged in,
>         $this->set('activeUser', $this->Auth->user());
>     } // end beforeFilter()
>
> Controller/UsersController.php:
>     public function login() {
>         if ($this->request->is('post')) {
>             if ($this->Auth->login()) {
>                 $this->redirect($this->Auth->redirect());
>             } else {
>                 $this->Session->setFlash('Your username or password was 
> incorrect.');
>             }
>         }
>     } // end login()
>
>     public function logout() {
>         $this->Session->setFlash('Good-Bye');
>         $this->redirect($this->Auth->logout());  // from auth tutorial
>     } // end logout()
>
> /View/Users/login.ctp:
>     <div class="users form">
>         <?php echo $this->Form->create('User', array('action' => 
> 'login')); ?>
>         <fieldset>
>             <legend>Login</legend>
>             <?php
>                 echo $this->Form->input('username', array( 'style' => 
> 'width: 15em; padding: 2px;' ));
>                 echo $this->Form->input('password', array( 'style' => 
> 'width: 15em; padding: 2px;' ));
>             ?>
>         </fieldset>
>         <?php
>             echo $this->Form->submit('Login');
>             echo $this->Form->end();
>         ?>
>     </div> <!-- class="users form" -->
>
>

-- 
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+unsubscr...@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to