标签: cakephp-3.8

Cakephp 3 身份验证插件,登录 URL 不匹配

我想使用 CakePHP 3.8 的身份验证插件,但我遇到了文档中没有的问题。

在遵循入门 ( https://book.cakephp.org/authentication/1/en/index.html ) 之后,我有一个问题。

最初指定 $fields 来更改真实数据库中的用户名和密码关系,与 Auth 组件相同,登录 URL 是登录表单 si 加载的位置。

首先,在入门或文档的任何部分都没有说明登录视图(表单),因此,像旧的 Auth 组件一样,我将其创建到 Users/login.ctp

<div class="users form">
    <?= $this->Flash->render('auth') ?>
    <?= $this->Form->create() ?>
    <fieldset>
        <legend><?= __('Please enter your email and password') ?></legend>
        <?= $this->Form->input('email') ?>
        <?= $this->Form->input('password') ?>
    </fieldset>
    <?= $this->Form->button(__('Login')); ?>
    <?= $this->Form->end() ?>
</div>
Run Code Online (Sandbox Code Playgroud)

我在 Application.php 中的代码包括这个(及其各自的用途和实现):

    public function getAuthenticationService(ServerRequestInterface $request, ResponseInterface $response)
    {
        $service = new AuthenticationService();

        $fields = [
            'username' => 'email',
            'password' => 'password'
        ];

        // Load …
Run Code Online (Sandbox Code Playgroud)

authentication plugins cakephp cakephp-3.x cakephp-3.8

2
推荐指数
1
解决办法
1319
查看次数