so if i want to use authentication, how should i go about doing it?

Gangzheng

On Aug 24, 2:03 pm, Martin Westin <[email protected]> wrote:
> My guess is that Auth component is doing it.
> If you are doing your own authentication you have to remove Auth from
> your list of components. And if you do want to use Auth ten you
> shouldn't do any of the authenticating stuff yourself.
>
> /Martin
>
> On Aug 24, 6:50 am, liaogz82 <[email protected]> wrote:
>
> > Hi all,
>
> > I dont know why but my password is always sent as null in $this->data,
> > which causes it to be unable to retrieve data for comparison. The
> > following below are my codes:
>
> > login.ctp
> > <div class="login">
> > <h2>Login</h2>
> >     <?php echo $form->create('User', array
> > ('controller'=>'users','action'=>'login'));?>
> >         <?php echo $form->input('User.username');?>
> >         <?php echo $form->input('User.password',array
> > ('type'=>'password'));?>
> >         <?php echo $form->submit('Login');?>
> >     <?php echo $form->end(); ?>
> > </div> <?php
> > ?>
>
> > users_controller.php
> >     function login()
> >     {
> >         $this->layout = 'login';
> >         if(!empty($this->data))
> >         {
> >             $user = $this->User->validateLogin($this->data['User']);
> >             if($user != '')
> >             {
> >                 $this->Session->write('User', $user);
> >                 $this->Session->setFlash('You\'ve successfully logged
> > in.');
> >                 $this->redirect(array('controller'=>'subscribers',
> > 'actions'=>'index'));
> >             }
> >             else
> >             {
> >                 $this->Session->setFlash(json_encode($this->data));
> >                 $this->redirect(array
> > ('controller'=>'users','actions'=>'login'));
> >             }
> >         }
> >     }
>
> >     function logout()
> >     {
> >         $this->Session->destroy('user');
> >         $this->Session->setFlash('You\'ve successfully logged out.');
> >         $this->redirect($this->Auth->logout());
> >     }
>
> > user.php
> > class User extends AppModel {
>
> >     var $name = 'User';
> > //    var $actsAs = array('Acl' => array('requester'));
> >     var $useDbConfig = 'tracksdb';
>
> >     function parentNode() {
> >     }
>
> >     /* To get the login ID of staff
> >     function getStaffID()
> >     {
> >         return "gangzheng";
> >         /* to change. The ID should be gotten from session
> >     }*/
>
> >     //The Associations below have been created with all possible keys,
> > those that are not needed can be removed
> >     var $belongsTo = array(
> >             'Group' => array('className' => 'Group',
> >                                 'foreignKey' => 'group_id',
> >                                 'conditions' => '',
> >                                 'fields' => '',
> >                                 'order' => '',
> >                                 'counterCache' => ''),
> >     );
>
> >     var $hasMany = array(
> >             'Login' => array('className' => 'Login',
> >                                 'foreignKey' => 'user_id',
> >                                 'conditions' => '',
> >                                 'fields' => '',
> >                                 'order' => '',
> >                                 'limit' => '',
> >                                 'offset' => '',
> >                                 'dependent' => '',
> >                                 'exclusive' => '',
> >                                 'finderQuery' => '',
> >                                 'counterQuery' => ''),
> >     );
>
> >     function validateLogin($data)
> >     {
> >         $user = $this->find(array('username' => $data['username'],
> > 'password' => sha1($data['password'])), array('id', 'username'));
> >         if(empty($user) == false)
> >             return $user['User'];
> >         return false;
> >     }
>
> > }
>
> > The flash message kept showing {"User":
> > {"username":"gangzheng","password":null}}. So i am not sure what is
> > going on. the password field is always set to null no matter what i
> > type into the password field. Please help. Thanks
>
> > Gangzheng
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to