0
나는이 문제로 많은 어려움을 겪고 있습니다.beforeSave working cakePHP
public function register(){
if ($this->request->is('post')) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(
__('registration is successfully completed. you can login now.'),
'success',
array(),
'auth'
);
return $this->redirect(array('action' => 'login'));
}
$this->Session->setFlash(
__('The user could not be saved. Please, try again.'),
'error'
);
}
$this->layout = false;
}
내 모델 코드
class User extends AppModel {
App::uses('SimplePasswordHasher', 'Controller/Component/Auth');
$validate = array();
public function beforeSave($options = array()) {
parent::beforeSave();
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new SimplePasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash(
$this->data[$this->alias]['password']
);
}
return true;
}
}
컨트롤러의 저장 방법을 주셔서 감사합니다.
요청 데이터를 이미 create()에 넣으십시오. 또는 메서드가 호출되었지만 암호가 업데이트되지 않았 으면 디버그 할 수 있습니까? – lp1051