Note that there are some explanatory texts on larger screens.

plurals
  1. POCakephp authentication: 2.4.2
    primarykey
    data
    text
    <p>My problem is I have a different model name for the user table: Breeder. My login page always says incorrect username or password, because the password entered is not hashed.</p> <p>Here is the view:</p> <pre><code>&lt;?php echo $this-&gt;Form-&gt;create(); echo $this-&gt;Form-&gt;input('username'); echo $this-&gt;Form-&gt;input('password'); echo $this-&gt;Form-&gt;end('Log in'); echo $this-&gt;Html-&gt;link('Register', '/breeders/register'); ?&gt; </code></pre> <p>Here is the AppController:</p> <p>class AppController extends Controller {</p> <pre><code>public $helpers = array('Html', 'Form', 'Session'); public $components = array('Session', 'Paginator', 'Auth' =&gt; array( 'loginAction' =&gt; array('controller' =&gt; 'breeders', 'action' =&gt; 'login'), 'loginRedirect' =&gt; array('controller' =&gt; 'breeders', 'action' =&gt; 'desk'), 'logoutRedirect' =&gt; array('controller' =&gt; 'breeders', 'action' =&gt; 'login'), 'authorize' =&gt; array('Controller'), 'authenticate' =&gt; array( 'Form' =&gt; array( 'fields' =&gt; array( 'username' =&gt; 'login', 'password' =&gt; 'password'), 'passwordHasher' =&gt; array( 'className' =&gt; 'Simple', 'hashType' =&gt; 'sha256' ) ) ) ) ); public function isAuthorized($user) { return true; } public function beforeFilter() { $this-&gt;Auth-&gt;allow('login', 'logout', 'register', 'profile'); } } </code></pre> <p>My login method:</p> <pre><code>public function login() { $this-&gt;set('title_for_layout', __('Connection')); if ($this-&gt;Session-&gt;read('Auth.Breeder')) { return $this-&gt;redirect('/'); } if ($this-&gt;request-&gt;is('post')) { if ($this-&gt;Auth-&gt;login()) { return $this-&gt;redirect($this-&gt;Auth-&gt;redirectUrl()); } } } </code></pre> <p>And the beforeSave method in the model:</p> <pre><code>public function beforeSave($options = array()) { if (!$this-&gt;id) { $passwordHasher = new SimplePasswordHasher(); $this-&gt;data['Breeder']['password'] = $passwordHasher-&gt;hash( $this-&gt;data['Breeder']['password'] ); } return true; } </code></pre> <p>I don't know what I need to add to make the password be hashed. Any help will be welcome.</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.
 

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