Thursday, November 3, 2011

Problem Auth Component | CakePHP 2.0.2

hi Cake Community,

CakePHP 2.0.2
OS: Windows7
Configure::write('debug', 2);

Problem:
My Auth Component is not working and i dont know why. Need Help.


User Controller:

<?php

class UsersController extends AppController {
   
    public $components = array('Auth','Security');
       
    public function login() {
            if ($this->request->is('post')) {

                /* $this->Auth->User('usr') or $this->Auth->User('pwd') ....also tried. Returns nothing. Dont know why!?!?! */

                if ($this->Auth->Login()) {
                    $this->redirect(array('controller' => 'PricerobotStoreEngines', 'action' => 'index'));
                } else {
                    $this->Session->setFlash(__('Username or password is incorrect'));
                    $this->redirect(array('controller' => 'users', 'action' => 'login'));
                }
            }
           
    }
    public function logout() {
            $this->redirect($this->Auth->logout());
    }
   
    /*
     *  tried,too ! Returns nothing.
     * 
    public function beforeFilter(){
             // $this->Auth->User('usr') or $this->Auth->User('pwd') ....also tried. Returns nothing. Dont know why!?!?!
    }
     *
     *
     */ 

}
?>

PricerobotStoreEnginesController Controller:

<?php

class PricerobotStoreEnginesController extends AppController {
   
        public $components = array(
            'Auth'=> array(
                'loginAction' => array(
                    'controller' => 'users',
                    'action' => 'login',
                )
            )
        );

       etc............

}
?>

Login View:

<?php
    echo $this->Form->create('');
    echo $this->Form->input('usr');  
    echo $this->Form->password('pwd');
    echo $this->Form->end('Login');
?>








No comments: