如何使Laravel在忘记密码输入链接的同时寻找管理员模型?

时间:2019-09-13 07:01:45

标签: laravel

我有多个身份验证系统用户和管理员。 Laravel make:auth自动寻找用户模型。 我想让Make:auth忘记密码来查找Admin Model而不是User model。 我应该在哪里更改代码,因为当我在“发送密码重置”链接中键入电子邮件时,它说没有找到电子邮件,因为laravel正在检查用户模型而不是管理员模型。

1 个答案:

答案 0 :(得分:0)

看看config/auth.php,您必须提供多个重置密码表。

例如:

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

        'clients' => [
            'driver' => 'eloquent',
            'model' => App\Entities\Clients\Client::class,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Resetting Passwords
    |--------------------------------------------------------------------------
    |
    | You may specify multiple password reset configurations if you have more
    | than one user table or model in the application and you want to have
    | separate password reset settings based on the specific user types.
    |
    | The expire time is the number of minutes that the reset token should be
    | considered valid. This security feature keeps tokens short-lived so
    | they have less time to be guessed. You may change this as needed.
    |
    */

    'passwords' => [
        'users' => [
            'provider' => 'users',
            'table' => 'users_password_resets',
            'expire' => 60,
        ],
        'clients' => [
            'provider' => 'clients',
            'table' => 'clients_password_resets',
            'expire' => 60,
        ],
    ],

在那些示例中,我有多个身份验证提供程序:usersclients,因此我必须有单独的密码重置表。 users_password_resetclients_password_reset仅复制原始的password_reset迁移并进行相应的更新。