Hi,

After spending 2 days, finally I've found why it was not working.

In /lib/Cake/Controller/Component/Auth/FormAuthenticate.php on line
number 61,61 and 67,68 it is trying to access the undifined
"$fields['username'] and "$fields['password']  index
it should be only ['username'] and ['password'].

on line number 61 and 62 Just replace
     empty($request->data[$model][$fields['username']]) ||
empty($request->data[$model][$fields['password']])
With
     empty($request->data[$model]['username']) || empty($request-
>data[$model]['password'])

And on line number 67 ,68 replace
     $request->data[$model][$fields['username']],       $request-
>data[$model][$fields['password']]
with
     $request->data[$model]['username'],        $request->data[$model]
['password']

And for changing the model
if you set $model='User'  on line number  55 you can use the any other
model than default User.

That's it and you are done

Will appreciate If anyone can modify it in cakaPHP ways...


Thanks
Vaibhav

On Jan 6, 2:17 pm, "vaibhav.malushte" <[email protected]>
wrote:
> 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