use this when displaying pwd fields:
http://www.dereuromark.de/2011/08/25/working-with-passwords-in-cakephp/


Am Montag, 28. Mai 2012 22:00:22 UTC+2 schrieb Richard:
>
> I am sure there are a lot better solutions than this, and more brilliant 
> coders can help you out, but at least this is what I did.
>
> I used password and password2 (or reEnterPassword however your call it) on 
> edit.ctp
> and use two different rules from the User model
>
> on Model, you will need public $validation as your default rule,
> then create public $validationSets (you need a plugin for this.  I think 
> it is multivalidate)
> and you would create validation something like
>
> public $validationSets = array(
>
> 'edit' => array(
>
> YOU DO ADD PASSWORD SECTION HERE
>
> },
> 'add' => array(
>
> whatever rule you want
>
> },
> 'editWithOutPassword' => array(
>
> Rules WITHOUT PASSWORD HERE
>
> )
>
> );
>
>
> Then on UsersController.php, you would call it something like
>
> public function edit($id = null) {
>
> if edit with password {
>
> $this->User->setValidation('edit');
> and do whatever your code here
>
> } else {
>
> $this->User->setValidation('editWithOutPassword');
>
> And here, you will have to compile your own list of forms you need to save 
> without password.
> something like
> $fieldsToUpdate = array(your field list here);
> $formValues = array(your form values here);
> $this->User->read($fieldsToUpdate, $id);
> $this->User->set($formValues);
>
> and rest of your save code here
> if($this->User->save()) {
>
> User has been saved
>
> } else {
>
> User could not be saved.
>
> }
>
> }
>
> }
>
> On Mon, May 28, 2012 at 12:20 PM, lsri8088 <[email protected]> wrote:
>
>> Hello,
>>
>> I'm using cake 2.1 with AuthComponent and standard data modelusers.
>>
>> How I can edit a user without changing the password?
>>
>> For example, add a check "I want to change the password." If thischeck is 
>> true then I make a hash of the password and keep it inserted.Otherwise I 
>> do not modify the password field.
>> How do I add this check and then check it in my beforeSave() function?
>>
>> Another option I can think of is to leave the password field empty when 
>> I go to edit a user (unset ($ this-> request-> data ['User'] ['password']) 
>> ;)and then check if the password is empty or not. But .... when I insert a 
>> new user the password field should be mandatory ....
>>
>> Do you have any ideas?
>>
>> thanks
>>
>> -- 
>> 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
>>
>
>
>
> -- 
> Richard Joo
>
>  

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