неверный логин в cakephp, даже все правильно - PullRequest
0 голосов
/ 04 июня 2019

Я новичок в CakePHP - это удивительная среда PHP, я пытаюсь создать новое приложение, поэтому я попадаю на часть страницы входа, это мой код, когда я пытаюсь войти в систему, я получаю «неверный логин» и парольхэшируется

AppController

public function beforeFilter(Event $event) {
        $this->Auth->allow('display');
}

public function initialize()
{
    parent::initialize();

    $this->loadComponent('RequestHandler', [
        'enableBeforeRedirect' => false,
    ]);
    $this->loadComponent('Flash');
    $this->loadComponent('Auth', [
            'authenticate' => [
                'Form' => [
                    'fields' => [
                        'username' => ' email',
                        'password' => 'password'
                    ]
                ]
            ],
            'loginAction' => [
                'controller' => 'user',
                'action' => 'login'
            ]
        ]);

    /*
     * Enable the following component for recommended CakePHP security settings.
     * see https://book.cakephp.org/3.0/en/controllers/components/security.html
     */
    //$this->loadComponent('Security');
}
}

// UserController

public function login(){
    if($this->request->is('post')){
        $user = $this->Auth->identify();
        if($user){
            $this->Auth->setUser($user);
            return $this->redirect(['controller' => 'reference']);
        }
        // Bad Login
        $this->Flash->error('Incorrect Login');
    }
}

// Logout
public function logout(){
     $this->Flash->success('You are logged out');
     return $this->redirect($this->Auth->logout());
}

// Login.ctp

<div class="users form">
<?= $this->Flash->render() ?>
<?= $this->Form->create() ?>
    <fieldset>
        <legend><?= __("Merci de rentrer vos nom d'utilisateur et mot de passe") ?></legend>
        <?= $this->Form->control('username') ?>
        <?= $this->Form->control('password') ?>
    </fieldset>
<?= $this->Form->button(__('Se Connecter')); ?>
<?= $this->Form->end() ?>
</div>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...