title: Change password for a user in CakePHP 2.1
body: <p>I'm building a page where a user can change their password. They must fill two fields and both must match before it will be changed and then they will be redirected to their profile page on success.</p>
  
  <p>So far I have built the following method:</p>
  
  <pre><code>public function changePassword()
  {
  
      $user = $this-&gt;User-&gt;find('first', array( 
                  'conditions' =&gt; array(
                      'User.id' =&gt; $this-&gt;Auth-&gt;user('id')) 
              ));
  
      if ($this-&gt;request-&gt;is('post') || $this-&gt;request-&gt;is('put'))
      {
          if ($this-&gt;User-&gt;save($this-&gt;request-&gt;data))
          {
              $this-&gt;User-&gt;saveField('password', AuthComponent::password($this-&gt;request-&gt;data['User']['password2']));
  
              $this-&gt;Session-&gt;setFlash(__('Your password has been changed!'));
              $this-&gt;redirect(array('controller'=&gt;'profiles','action'=&gt;'view','userName'=&gt;$user['User']['username']));
          }
          else
          {
              $this-&gt;Session-&gt;setFlash(__('Whoops! Something went wrong... try again?'));
          }
      }
  
  }
  </code></pre>
  
  <p>and this is the form:</p>
  
  <pre><code>&lt;?php echo $this-&gt;Form-&gt;create(); ?&gt;
  
      &lt;?php echo $this-&gt;Form-&gt;input('id',array('type'=&gt;'hidden')); ?&gt;
  
      &lt;?php echo $this-&gt;Form-&gt;input('password1',array('type'=&gt;'text','label'=&gt;array('text'=&gt;'Enter your new password'))); ?&gt;
  
      &lt;?php echo $this-&gt;Form-&gt;input('password2',array('type'=&gt;'text','label'=&gt;array('text'=&gt;'Confirm your new password'))); ?&gt;
  
      &lt;button type="submit"&gt;Save&lt;/button&gt;
  
  &lt;?php echo $this-&gt;Form-&gt;end(); ?&gt;
  </code></pre>
  
  <p>So as you can see the plan is to take what it says in password2 and save it in the database password field using the security hashing. But what happens is it creates a new user instead but with blank data... What am I doing wrong here? And how do I compare the two password fields...</p>