Re: Please Help!! my password is always null!!!

2009-08-24 Thread Martin Westin

If you want to do it all yourself then just remove "Auth" from your
list of components.
Most likely you want to let AuthComponent help you out and in that
case there are numerous tutorials to choose from. You can always start
with the cookbook:
http://book.cakephp.org/view/172/Authentication

/Martin


On Aug 24, 9:06 am, liaogz82  wrote:
> so if i want to use authentication, how should i go about doing it?
>
> Gangzheng
>
> On Aug 24, 2:03 pm, Martin Westin  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  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
> > > 
> > > Login
> > >     create('User', array
> > > ('controller'=>'users','action'=>'login'));?>
> > >         input('User.username');?>
> > >         input('User.password',array
> > > ('type'=>'password'));?>
> > >         submit('Login');?>
> > >     end(); ?>
> > >   > > ?>
>
> > > 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~---

Re: Please Help!! my password is always null!!!

2009-08-24 Thread liaogz82

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

Gangzheng

On Aug 24, 2:03 pm, Martin Westin  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  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
> > 
> > Login
> >     create('User', array
> > ('controller'=>'users','action'=>'login'));?>
> >         input('User.username');?>
> >         input('User.password',array
> > ('type'=>'password'));?>
> >         submit('Login');?>
> >     end(); ?>
> >   > ?>
>
> > 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Please Help!! my password is always null!!!

2009-08-23 Thread thatsgreat2345

$form->create('User', array('url'=>array
('controller'=>'users','action'=>'login')));

On Aug 23, 9:50 pm, liaogz82  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
> 
> Login
>     create('User', array
> ('controller'=>'users','action'=>'login'));?>
>         input('User.username');?>
>         input('User.password',array
> ('type'=>'password'));?>
>         submit('Login');?>
>     end(); ?>
>   ?>
>
> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Please Help!! my password is always null!!!

2009-08-23 Thread Martin Westin


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  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
> 
> Login
>     create('User', array
> ('controller'=>'users','action'=>'login'));?>
>         input('User.username');?>
>         input('User.password',array
> ('type'=>'password'));?>
>         submit('Login');?>
>     end(); ?>
>   ?>
>
> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Please Help!! my password is always null!!!

2009-08-23 Thread liaogz82

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

Login
create('User', array
('controller'=>'users','action'=>'login'));?>
input('User.username');?>
input('User.password',array
('type'=>'password'));?>
submit('Login');?>
end(); ?>
 

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---