Note that there are some explanatory texts on larger screens.

plurals
  1. POcakephp check password with profile update
    primarykey
    data
    text
    <p>I am newbie to cake php and I have a problem. When a user updates his profile iam asking to enter his password.Now I dont know how to check it with the stored password.</p> <pre><code> &lt;?php echo $form-&gt;create('UserProfile', array('url' =&gt; array('action' =&gt; 'edit_profile', 'controller' =&gt; 'users'))); ?&gt; &lt;?php echo $form-&gt;input('nickname', array('label' =&gt; __('Display Name', true), 'class' =&gt; 'INPUT required')); ?&gt; &lt;b&gt;To save these settings, please enter your password&lt;/b&gt;&lt;br /&gt;&lt;br /&gt; &lt;?php echo $form-&gt;input('repeat_password', array('label' =&gt; __('Password', true), 'class' =&gt; 'INPUT required','type'=&gt;'password')); echo $form-&gt;input('private', array('label' =&gt; __('Set Profile Private', true), 'class' =&gt; 'INPUT required')); ?&gt; &lt;!-- &lt;div id="CityList"&gt; &lt;?php // echo $form-&gt;input('city', array('id' =&gt; 'citySelect', 'name' =&gt; 'data[UserProfile][city]', 'empty' =&gt; __('Please select city', true), 'label' =&gt; __('City', true), 'class' =&gt; 'INPUT required')); ?&gt; &lt;/div&gt; --&gt; &lt;?php echo $form-&gt;submit(__('Submit', true), array('class' =&gt; 'save_btn')) ?&gt;` &gt; </code></pre> <p>In My model i have applied the following validation on repeat password.</p> <pre><code> 'repeat_password' =&gt; array( array('rule' =&gt; 'check_repeatPassword'), array('rule' =&gt; 'notempty', 'message' =&gt; __('Required', true), 'require' =&gt; true), array('rule' =&gt; 'alphaNumeric', 'allowEmpty' =&gt; true, 'message' =&gt; __('Password must only contain letters and numbers.', true)), array('rule' =&gt; array('minLength', 6), 'allowEmpty' =&gt; true, 'message' =&gt; __('Password must be at least 6 characters long.', true)), array('rule' =&gt; array('maxLength', 16), 'allowEmpty' =&gt; true, 'message' =&gt; __('Password must be at most 16 characters long.', true)) ), function check_repeatPassword($data) { $repeatPassword = $data['repeat_passowrd']; $passwordExists = $this-&gt;find('count', array('conditions' =&gt; array('User.repeat_password' =&gt; $repeatPassword))); if ($passwordExists == 0) { return false; } return true; } </code></pre> <p>In My Controller I have made the following edit profile method.</p> <pre><code> function edit_profile() { $this-&gt;loadModel('UserProfile'); $user = $this-&gt;_authenticate_user(); $id = $user['account_num']; if (!empty($this-&gt;data)) { $this-&gt;data['UserProfile']['account_name'] = $id; unset($this-&gt;data['UserProfile']['country']); unset($this-&gt;data['UserProfile']['city']); if ($this-&gt;UserProfile-&gt;save($this-&gt;data)) { $userInfo = $this-&gt;User-&gt;getUserInfo($id); $this-&gt;User-&gt;reassign_session($userInfo); $this-&gt;flashMessage(__('Your Profile has been Updated successfully', true), 'Sucmessage'); //$this-&gt;redirect(array('action' =&gt; 'profile')); } else { $this-&gt;flashMessage(__('Your Profile has not been updated. Please, try again.', true)); } } if (empty($this-&gt;data)) { $this-&gt;data = $this-&gt;UserProfile-&gt;read(null, $id); } // $this-&gt;loadModel('Country'); // $countries = $this-&gt;Country-&gt;find('list'); // $this-&gt;set('countries', $countries); $this-&gt;loadModel('Nationality'); $nationalities = $this-&gt;Nationality-&gt;find('list', array('fields' =&gt; array('name', 'name'))); $this-&gt;set('nationalities', $nationalities); $this-&gt;pageTitle = __('Edit My Profile', true); } Kindly help me how to do this.Thankssssss in advance </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload