おはようございます。私は大きな問題を抱えています。私はajaxで入力するためにいくつかのパラメータを使用していますが、このコードにAjaxを送信すると、何もせずにリダイレクトされます。私はあなたがより良い方法を持っていると信じていますが、ドキュメンテーションは何も説明していません!あなたが私を助けることができれば、ありがとう!Cakephp 3 - Ajaxログイン
class ContaController extends AppController {
public function initialize() {
parent::initialize();
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'authenticate' => [
'Form' => [
'fields' => ['username' => 'email', 'password' => 'senha'],
'userModel' => 'Conta',
]
],
'loginAction' => [
'controller' => 'Conta',
'action' => 'index'
],
'loginRedirect' => [
'controller' => 'Conta',
'action' => 'minhaAgenda'
],
'logoutRedirect' => [
'controller' => '/'
],
'storage' => 'Memory'
]);
$this->Auth->allow(['index']);
}
public function index() {
if ($this->request->is('ajax') || $this->request->is('post')) {
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
echo 'success';
} else {
echo 'incorrect';
}
}
}
public function sair() {
return $this->redirect($this->Auth->logout());
}
}
あなたはビューファイルを共有できますか? –