ackintosh

https://ackintosh.github.io/about/ に引っ越しました ☺

<CakePHP> パスワードをDBに保存する前にハッシュ化する

app/Model/User.php

<?php
App::uses('AuthComponent', 'Controller/Component');
class User extends AppModel {
   
    public function beforeSave()
    {
        $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
        return true;
    }
}
?>