Note that there are some explanatory texts on larger screens.

plurals
  1. POCakephp - checkPasswords is always false
    primarykey
    data
    text
    <p>I'm working on the signup process and want to check if the two passwords (password + re-entered password) are equal. These are my validation rules in the User Model:</p> <pre><code>var $validate = array( 'username' =&gt; array( 'notEmpty' =&gt; array( 'rule' =&gt; array('minLength', 5), 'required' =&gt; true, 'allowEmpty' =&gt; false, 'message' =&gt; 'User name has to be at least 5 characters long' ), array( 'rule' =&gt; 'isUnique', 'message' =&gt; 'User name taken. Use another' ) ), 'password' =&gt; array( 'notEmpty' =&gt; array( 'rule' =&gt; array('minLength', 6), 'required' =&gt; true, 'allowEmpty' =&gt; false, 'message' =&gt; 'Password has to be at least 6 characters long' ), 'password_similar' =&gt; array( 'rule' =&gt; 'checkPasswords', 'message' =&gt; 'Entered passwords does not match' ) ), 'email' =&gt; array( 'rule' =&gt; 'email', 'required' =&gt; true, 'allowEmpty' =&gt; false, 'message' =&gt; 'Please enter a valid email' ) ); </code></pre> <p>In the <code>users_controller.php</code> I have the <code>checkPasswords</code> function:</p> <pre><code>function checkPasswords($data) { if($data['password'] == $this-&gt;data['User']['password2hashed']) return true; else return false; } </code></pre> <p>An my singup function looks like this:</p> <pre><code>function signup(){ if (!empty($this-&gt;data)) { if(isset($this-&gt;data['User']['password2'])) $this-&gt;data['User']['password2hashed'] = $this-&gt;Auth-&gt;password($this-&gt;data['User']['password2']); $this-&gt;User-&gt;create(); if ($this-&gt;User-&gt;save($this-&gt;data)) { . . . } </code></pre> <p>No matter what I do, the passwords do not match. Even if I change the <code>checkPasswords</code> function to this:</p> <pre><code>function checkPasswords($data) { return true; } </code></pre> <p>What could cause this behavior?</p>
    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.
    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