首页 > 解决方案 > UnexpectedValueException 用户必须实现 CanResetPassword 接口

问题描述

我正在使用 laravel 6,我在重置密码时遇到问题,我进行了总和研究,但没有任何效果。他们中的大多数人告诉我添加 CanResetPassword,我已经添加了它但仍然没有。

这是我的 User.php 类

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
   use Notifiable;

   ....
}

配置:身份验证

我刚刚添加了一个名为 password 的新提供程序,它使用 eloquent。我认为这可能是不好的做法,但它不再显示相同的错误。

'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],

        'users' => [
            'driver' => 'database',
            'table' => 'users',
        ],
        'password' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],
    ],

    'passwords' => [
        'users' => [
            'provider' => 'password',
            'table' => 'password_resets',
            'expire' => 60,
            'throttle' => 60,
        ],
    ],

这是我添加密码提供程序之前的情况

'providers' => [
        'users' => [
            'driver' => 'database',
            'table' => 'users',
        ],
        'password' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],
    ],

    'passwords' => [
        'users' => [
            'provider' => 'users',
            'table' => 'password_resets',
            'expire' => 60,
            'throttle' => 60,
        ],
    ],

标签: phplaravelauthentication

解决方案


推荐阅读