Note that there are some explanatory texts on larger screens.

plurals
  1. POPassword hashed twice?
    primarykey
    data
    text
    <p>I try tutorial Simple Acl controlled Application from CakePHP website and I have problem with hashing password.</p> <p>My tables are:</p> <pre><code>CREATE TABLE users ( id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255) NOT NULL UNIQUE, pwd CHAR(40) NOT NULL, group_id INT(11) NOT NULL </code></pre> <p>);</p> <pre><code>CREATE TABLE groups ( id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL </code></pre> <p>);</p> <p>And in model User.php I have:</p> <pre><code>public function beforeSave($options = array()) { $this-&gt;data['User']['pwd'] = AuthComponent::password($this-&gt;data['User']['pwd']); return true; } </code></pre> <p>If I click on website on Edit User and then Submit, pwd is hashed again. How can I fix that?</p> <p>I try from this forum:</p> <pre><code>public function beforeSave($options = array()) { if(!empty($this-&gt;data['User']['pwd'])) { $this-&gt;data['User']['pwd'] = AuthComponent::password($this-&gt;data['User']['pwd']); } else { unset($this-&gt;data['User']['pwd']); } return true; </code></pre> <p>}</p> <p>But it is not working.</p> <p>My edit.ctp:</p> <pre><code>&lt;div class="users form"&gt; &lt;?php echo $this-&gt;Form-&gt;create('User'); ?&gt; &lt;fieldset&gt; &lt;legend&gt;&lt;?php echo __('Edit User'); ?&gt;&lt;/legend&gt; &lt;?php echo $this-&gt;Form-&gt;input('id'); echo $this-&gt;Form-&gt;input('username'); echo $this-&gt;Form-&gt;input('pwd'); echo $this-&gt;Form-&gt;input('group_id'); ?&gt; &lt;/fieldset&gt; &lt;?php echo $this-&gt;Form-&gt;end(__('Submit')); ?&gt; &lt;/div&gt; &lt;div class="actions"&gt; &lt;h3&gt;&lt;?php echo __('Actions'); ?&gt;&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;&lt;?php echo $this-&gt;Form-&gt;postLink(__('Delete'), array('action' =&gt; 'delete', $this-&gt;Form-&gt;value('User.id')), null, __('Are you sure you want to delete # %s?', $this-&gt;Form-&gt;value('User.id'))); ?&gt;&lt;/li&gt; &lt;li&gt;&lt;?php echo $this-&gt;Html-&gt;link(__('List Users'), array('action' =&gt; 'index')); ?&gt;&lt;/li&gt; &lt;li&gt;&lt;?php echo $this-&gt;Html-&gt;link(__('List Groups'), array('controller' =&gt; 'groups', 'action' =&gt; 'index')); ?&gt; &lt;/li&gt; &lt;li&gt;&lt;?php echo $this-&gt;Html-&gt;link(__('New Group'), array('controller' =&gt; 'groups', 'action' =&gt; 'add')); ?&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p></p> <p>And add.ctp:</p> <pre><code>&lt;div class="users form"&gt; &lt;?php echo $this-&gt;Form-&gt;create('User'); ?&gt; &lt;fieldset&gt; &lt;legend&gt;&lt;?php echo __('Add User'); ?&gt;&lt;/legend&gt; &lt;?php echo $this-&gt;Form-&gt;input('username'); echo $this-&gt;Form-&gt;input('pwd'); echo $this-&gt;Form-&gt;input('group_id'); ?&gt; &lt;/fieldset&gt; &lt;?php echo $this-&gt;Form-&gt;end(__('Submit')); ?&gt; &lt;/div&gt; &lt;div class="actions"&gt; &lt;h3&gt;&lt;?php echo __('Actions'); ?&gt;&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;&lt;?php echo $this-&gt;Html-&gt;link(__('List Users'), array('action' =&gt; 'index')); ?&gt;&lt;/li&gt; &lt;li&gt;&lt;?php echo $this-&gt;Html-&gt;link(__('List Groups'), array('controller' =&gt; 'groups', 'action' =&gt; 'index')); ?&gt; &lt;/li&gt; &lt;li&gt;&lt;?php echo $this-&gt;Html-&gt;link(__('New Group'), array('controller' =&gt; 'groups', 'action' =&gt; 'add')); ?&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p></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.
 

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