Я пытаюсь войти в систему с POST и аутентификацией, однако безуспешно возвращающегося FALSE функцию "$ this-> auth-> определить()" в моем UsersControllerCakePHP 3.X Войти с POST + AUTH неудачу
Здесь мои настройки из AppController для просмотра
AppController
public function initialize() {
parent::initialize();
$this->loadComponent('Flash');
$this->loadComponent('Auth');
$this->loadComponent('Cookie');
}
function beforeFilter(Event $event) {
$this->Auth->allow('add');
$this->Auth->config('authorize','Controller',true);
$this->Auth->config('authenticate', ['Form' => ['fields' => ['username' => 'username', 'password' => 'password']]]);
$this->Auth->config('logoutRedirect', 'Homes/index',true);
$this->Auth->config('loginRedirect', 'Homes/index',true);
$this->Auth->config('loginAction', 'Users/login',true);
$this->Auth->config('loginError', 'Usuário e/ou senha incorreto(s)',true);
$this->Auth->config('authError', 'Você precisa fazer login para acessar esta página',true);
$this->Auth->config('userModel', 'Users',true);
}
UsersController
public function login() {
if ($this->request->is('post')) {
/* Here return FALSE */
if ($this->Auth->identify()) {
$this->Session->setFlash(__('Welcome, ' . $this->Auth->user('username')));
} else {
$this->Auth->flash('Login errado');
}
}
}
login.ctp
<?= $this->Form->create(); ?>
<?php // $this->Form->create('Users'); ?>
<fieldset>
<legend><?= __('Login') ?></legend>
<?php
echo $this->Form->input('username');
echo $this->Form->input('password');
?>
</fieldset>
<?= $this->Form->button(__('Login')) ?>
<?= $this->Form->end() ?>
таблицы MySQL имя пользователя и пароль VARCHAR 200
Ваш пароль был удален и сохранен правильно? –
debug ($ this-> request-> data()); в вашем контроллере входа и сравните с паролем вашего db – CoolLife