Re: How to save a record but not clear an empty field?

2009-08-24 Thread gedm

delocalizer and Dr. Loboto,

It works a treat.

In the controller after fetching the data I unset the password field.
The password then comes up blank in the edit form.

I then entered the beforeValidate function, you gave me, in the model
and it works perfectly.

Thanks for your help.


On Aug 24, 3:23 pm, delocalizer  wrote:
> Yes nice, I hadn't though of that. So you would test for:
> if (isset($this->data['User]]['password']) && $this->data['User']
> ['password'] == Security::hash(Configure::read('Security.salt')))
>
> On Aug 24, 1:27 pm, "Dr. Loboto"  wrote:
>
> > > If you do this you'll have to hash your own password rather than let
> > > Auth do it automatically, because Auth will hash a blank password and
> > > the 'if' condition will never be true.
>
> > If do not touch Auth hashing behavior password field can be checked
> > not as "notBlank" but by comparison with hashed empty string.
--~--~-~--~~~---~--~~
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: How to save a record but not clear an empty field?

2009-08-23 Thread delocalizer

Yes nice, I hadn't though of that. So you would test for:
if (isset($this->data['User]]['password']) && $this->data['User']
['password'] == Security::hash(Configure::read('Security.salt')))

On Aug 24, 1:27 pm, "Dr. Loboto"  wrote:
> > If you do this you'll have to hash your own password rather than let
> > Auth do it automatically, because Auth will hash a blank password and
> > the 'if' condition will never be true.
>
> If do not touch Auth hashing behavior password field can be checked
> not as "notBlank" but by comparison with hashed empty string.
--~--~-~--~~~---~--~~
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: How to save a record but not clear an empty field?

2009-08-23 Thread Dr. Loboto

> If you do this you'll have to hash your own password rather than let
> Auth do it automatically, because Auth will hash a blank password and
> the 'if' condition will never be true.

If do not touch Auth hashing behavior password field can be checked
not as "notBlank" but by comparison with hashed empty string.
--~--~-~--~~~---~--~~
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: How to save a record but not clear an empty field?

2009-08-23 Thread delocalizer

Hi Gerard;
There would be many ways to do this - one way would be to put some
logic in the User model beforeValidate method that checks if password
field is set in the data but blank, then password field is unset - so
it won't be validated or saved.
eg.
function beforeValidate(){
if (isset($this->data['User']['pwd'] && strlen($this->data['User']
['pwd'])==0)){
unset($this->data['User']['pwd]);
}
return true;
}
If you do this you'll have to hash your own password rather than let
Auth do it automatically, because Auth will hash a blank password and
the 'if' condition will never be true.

On Aug 24, 12:04 am, gedm  wrote:
> I'm wondering how the cakephp bakery site ignores the blank password
> field when a user is updating their profile?
>
> That is, if the password is left blank it updates the other fields in
> the record but does not clear the password when the record is saved.
> How is this done?
>
> Thanks
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to save a record but not clear an empty field?

2009-08-23 Thread gedm

I'm wondering how the cakephp bakery site ignores the blank password
field when a user is updating their profile?

That is, if the password is left blank it updates the other fields in
the record but does not clear the password when the record is saved.
How is this done?

Thanks

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