사용자를 편집하려고하면 로그인 양식이 표시됩니다. 로그인하려고하면 '사용자 이름 및/또는 비밀번호가 잘못되었습니다'라는 메시지가 나타납니다. UsersController. 사용자 이름과 암호가 맞더라도. cakePHP : 사용자의 편집 페이지로 이동하려면 로그인 할 수 없습니다.
내 사용자 테이블 :1 user_id bigint(11) AUTO_INCREMENT
2 user_username varchar(45) utf8_general_ci
3 user_email varchar(255) utf8_general_ci
4 user_password varchar(255) utf8_general_ci
5 user_image varchar(255) utf8_general_ci
6 user_created timestamp CURRENT_TIMESTAMP
7 user_modified timestamp
8 user_deleted timestamp
9 user_lastlogin timestamp
10 user_locked timestamp
11 user_confirmed timestamp
12 person_id bigint(20)
이 내 사용자 모델에 있습니다
public function beforeSave($options=array()){
parent::beforeSave();
if (!empty($this->data['User']['user_password'])){
$this->data['User']['user_password'] = Security::hash($this->data['User']['user_password'], 'sha256', true);
}
return true;
}
이 내의 AppController에 있습니다
public $components = array(
'DebugKit.Toolbar',
'Session',
'Auth' => array(
'authenticate' => array(
'Form' => array(
'fields' => array(
'username' => 'user_username',
'password' => 'user_password'
),
'passwordHasher' => array(
'className' => 'Simple',
'hashType' => 'sha256'
)
)
),
'loginRedirect' => array('controller'=>'users', 'action'=>'index'),
'logoutRedirect' => array('controller'=>'users', 'action'=>'index'),
'AuthError' => 'You cannot access that page',
'authorize'=>array('Controller')
)
);
public function isAuthorized($user){
return true;
}
public function beforeFilter() {
$this->Auth->allow('index', 'view');
}
이 내 login.ctp
에echo $this->Form->create();
echo $this->Form->input('user_username');
echo $this->Form->input('user_password', array('type'=>'password'));
echo $this->Form->end('Submit');
01 23,516,
이 내 UsersController에 : 나는이에 잠시 동안 찾아 봤는데
public function beforeFilter(){
parent::beforeFilter();
$this->Auth->allow('add');
}
public function login(){
if ($this->request->is('post')){
if($this->Auth->login()){
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(_('The username and/or password is incorrect'));
}
}
}
public function logout(){
$this->redirect($this->Auth->logout());
}
. user_password의 이름을 password로 변경하고 Type을 변경하고 varchar (255)를 (40)으로 변경하면 아무 것도 해결되지 않는 것 같습니다. 어쩌면 해싱과 관련이 있을지 모르지만 나는 그 일을 제대로 수행했다고 생각합니다.
IIS와 함께 일하고 있습니다. 일종의 구성이 필요합니까?
나를 도와 줄 사람이 있습니까?
http://book.cakephp.org/2.0/en/core-libraries/components/ authentication.html – andtxr
원본 답변을 새로 작성하는 대신 편집 할 수 있습니다. – ndm
상기시켜 주셔서 감사합니다. ;) – andtxr