내가 만든 설명서에 따라 cakePHP 2.4에서 사용자를 로그인 할 수 없습니다. 이 (가) 성공적으로에 로그인하고 도착 URL (사용자/로그인 된 작업)로 리디렉션되지만 $this->Auth->username
및 $this->Auth->password
은 비워두면 세션이 생성되지 않습니다. 또한 잘못된 자격 증명을 사용하여 로그인을 시도하면 리디렉션됩니다. 또한 로그인이 성공했다고 알려줍니다. 나는 지금 우둔 해.cakePHP의 인증 2.4
AppController.php
class AppController extends Controller {
public $components = array(
'Session',
'DebugKit.Toolbar',
'Auth' => array(
'loginAction' => array('controller' => 'users', 'action' => 'login', 'plugin' => false),
'loginRedirect' => array('controller' => 'users', 'action' => 'loggedin'),
'logoutRedirect' => array('controller' => 'users', 'action' => 'loggedout'),
'authError' => 'UNABLE TO LOG IN.'
)
);
public function beforeFilter(){
$this->Auth->userModel = 'User';
$this->Auth->fields = array('username' => 'username', 'password' => 'password');
$this->Auth->allow('index','display','login','show_reg_form', 'view','signup');
}
}
UsersController.php
난 단지 로그인 기능 붙여 넣을 수 있습니다 :
public function login() {
if ($this->request->is('post')) {
if($this->Auth->login(/*$this->request->data*/)){
$this->Session->setFlash(__('Successfully logged in.'));
return $this->redirect($this->Auth->redirectUrl());
} else {
$this->Session->setFlash(__('Invalid username or password, try again'));
}
}
}
login.ctp
을3210관련 부분은 다음과 같습니다
<div class="container-login users form">
<?php echo $this->Form->create('User');
echo $this->Form->input('username');
echo $this->Form->input('password');
echo $this->Form->end(__('Login',true));?>
</div>
'__ ('로그인', 참)'__ ('로그인')'이어야합니다. 이것은 더 이상 cake1.3이 아닙니다. – mark
$ this-> Auth-> login에 매개 변수를 전달합니까? 아니면 방금 여기에 댓글을 달았습니까? –
나는 그 부분을 주석 처리하지 않았기 때문에 아무것도 로그인하지 않았기 때문에 나는 그들을 지나치지 않고있다. 설명서를 읽었을 때, 지정된 인수없이 작동해야합니다. –