Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use PasswordableBehavior with CakePHP?
    primarykey
    data
    text
    <p>Since vanilla CakePHP doesn't handle password fields very well on user edit views (echoing the hashed password into the password field, etc), I'm trying to use dereuromark's PasswordableBehavior to handle user registration and password updates. </p> <p>I tried following the tutorial (<a href="http://www.dereuromark.de/2011/08/25/working-with-passwords-in-cakephp/" rel="nofollow">http://www.dereuromark.de/2011/08/25/working-with-passwords-in-cakephp/</a>) making the following changes, but the server keeps throwing an error. What is the problem here? Because the error is in PasswordableBehavior.php, I'm not 100% certain I'm screwing up.</p> <p><strong>UsersController.php:</strong></p> <pre><code>public function register() { if ($this-&gt;request-&gt;is('post') || $this-&gt;request-&gt;is('put')) { $this-&gt;User-&gt;Behaviors-&gt;attach('Tools.Passwordable'); if ($this-&gt;User-&gt;save($this-&gt;request-&gt;data, true, array('username', 'name', 'email', 'pwd', 'pwd_repeat', 'group_id'))) { $this-&gt;Session-&gt;setFlash(__('The user has been saved'), 'flash/success'); $this-&gt;redirect(array('action' =&gt; 'index')); } else { $this-&gt;Session-&gt;setFlash(__('The user could not be saved. Please, try again.'), 'flash/error'); } unset($this-&gt;request-&gt;data['User']['pwd']); unset($this-&gt;request-&gt;data['User']['pwd_repeat']); } </code></pre> <p>and <strong>register.ctp</strong> (possible security hole alert)</p> <pre><code>&lt;?php echo $this-&gt;Form-&gt;create('User', array('role' =&gt; 'form')); echo $this-&gt;Form-&gt;input('username', array('class' =&gt; 'form-control')); echo $this-&gt;Form-&gt;input('name', array('class' =&gt; 'form-control')); echo $this-&gt;Form-&gt;input('email', array('class' =&gt; 'form-control')); echo $this-&gt;Form-&gt;input('password', array('class' =&gt; 'form-control')); echo $this-&gt;Form-&gt;hidden('group_id', array('value'=&gt;3)); echo $this-&gt;Form-&gt;submit('Submit', array('class' =&gt; 'btn btn-large btn-primary')); echo $this-&gt;Form-&gt;end(); </code></pre> <p>Finally, the server error:</p> <pre><code>Strict (2048): Declaration of PasswordableBehavior::beforeValidate() should be compatible with ModelBehavior::beforeValidate(Model $model, $options = Array) [APP/Plugin/Tools/Model/Behavior/PasswordableBehavior.php, line 338] Strict (2048): Declaration of PasswordableBehavior::beforeSave() should be compatible with ModelBehavior::beforeSave(Model $model, $options = Array) [APP/Plugin/Tools/Model/Behavior/PasswordableBehavior.php, line 338] </code></pre>
    singulars
    1. This table or related slice is empty.
    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