Hi,

I've followed the steps to set-up  Auth component (cakaphp 2.0), but
no luck so far, bellow is my configuration

in AppController :-

public $components = array(
        'Session',
        'Security',
        'Auth' => array(
        'loginAction' => array('controller' => 'users','action' =>
'login'), //this set the login controller and the action
                                'authenticate' => array(
 
'Form' => array(
 
'userModel' => 'User',
 
'scope'=>array('User.is_active' => 0),
 
'fields' => array('username' => 'username','password'=>'password')
                                                                       )
                                                                ),
            'loginRedirect' => array('controller' =>
'maildirect_home', 'action' => 'index'),
            'logoutRedirect' => array('controller' =>
'maildirect_home', 'action' => 'loggedout')
        )
    );

public function beforeFilter() {
         parent::beforeFilter();
}

====================================================================================
in User (model) : -
App::uses('AuthComponent', 'Controller/Component');

class User extends AppModel {

    public $name = 'Client';
    public $useTable = 'clients_users'; // I'm using different table
}
====================================================================================
in View :--
<div class="users form">
<?php echo $this->Session->flash('auth'); ?>
<?php echo $this->Form->create('User');?>
    <fieldset>
        <legend><?php echo __('Please enter your username and
password'); ?></legend>
    <?php
        echo $this->Form->input('username');
        echo $this->Form->input('password');
    ?>
    </fieldset>
<?php echo $this->Form->end(__('Login'));?>
</div>
====================================================================================

in UserController :-

class UsersController extends AppController {

    public function beforeFilter() {
        parent::beforeFilter();
        //$this->Auth->allow('add', 'logout', 'loggedout');
    }

    public function login() {
        if ($this->Auth->login()) {
            $this->redirect($this->Auth->redirect());
        } else {
            $this->Session->setFlash(__('Invalid username or password,
try again'));
        }
    }

    public function logout() {
        $this->redirect($this->Auth->logout());
    }
}

====================================================================================

Now I want to change the default model to my own model, First I've
change "'userModel' => 'User'" to 'userModel' => 'Client'" no luck
then I tried $this->Auth->userModel = 'Client';  but same result.
If I change the model name it redirect me to a login page with no
query executed in debug console.

Also I've tried to change the default fields name as 'fields' =>
array('username' => 'username','password'=>'password') to 'fields' =>
array('username' => 'user_name','password'=>'user_password'). This
also not working.
It gives me error column "username" not found in table (it's obvious,
there no filed "username", I've change it to "user_name")

I don't understand where I'm wrong :(

Please correct me if I'm doing anything wrong

Thanks and happy new year
Vaibhav

-- 
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

Reply via email to