Laravel 密码重置以进行多重身份验证

Wol*_*ler 5 php authentication laravel eloquent

我对正在运作的公司有第二个授权。但我唯一遇到的问题是为公司发送密码令牌电子邮件。它始终发送用户的电子邮件。

\n\n

那\xc2\xb4s是我的app/config/auth.php

\n\n

如果我更改默认密码值对公司有效,但仅适用于公司而不适用于用户。

\n\n

返回 [

\n\n
/*\n|--------------------------------------------------------------------------\n| Authentication Defaults\n|--------------------------------------------------------------------------\n|\n| This option controls the default authentication "guard" and password\n| reset options for your application. You may change these defaults\n| as required, but they\'re a perfect start for most applications.\n|\n*/\n\n\'defaults\' => [\n    \'guard\' => \'web\',\n    \'passwords\' => \'users\',\n],\n\n/*\n|--------------------------------------------------------------------------\n| Authentication Guards\n|--------------------------------------------------------------------------\n|\n| Next, you may define every authentication guard for your application.\n| Of course, a great default configuration has been defined for you\n| here which uses session storage and the Eloquent user provider.\n|\n| All authentication drivers have a user provider. This defines how the\n| users are actually retrieved out of your database or other storage\n| mechanisms used by this application to persist your user\'s data.\n|\n| Supported: "session", "token"\n|\n*/\n\n\'guards\' => [\n    \'web\' => [\n        \'driver\' => \'session\',\n        \'provider\' => \'users\',\n    ],\n\n    \'company\' => [\n        \'driver\' => \'session\',\n        \'provider\' => \'companies\',\n    ],\n\n    \'api\' => [\n        \'driver\' => \'token\',\n        \'provider\' => \'users\',\n    ],\n],\n\n/*\n|--------------------------------------------------------------------------\n| User Providers\n|--------------------------------------------------------------------------\n|\n| All authentication drivers have a user provider. This defines how the\n| users are actually retrieved out of your database or other storage\n| mechanisms used by this application to persist your user\'s data.\n|\n| If you have multiple user tables or models you may configure multiple\n| sources which represent each model / table. These sources may then\n| be assigned to any extra authentication guards you have defined.\n|\n| Supported: "database", "eloquent"\n|\n*/\n\n\'providers\' => [\n    \'users\' => [\n        \'driver\' => \'eloquent\',\n        \'model\' => App\\User::class,\n    ],\n\n    \'companies\' => [\n        \'driver\' => \'eloquent\',\n        \'model\' => App\\Company::class,\n    ],\n\n    // \'users\' => [\n    //     \'driver\' => \'database\',\n    //     \'table\' => \'users\',\n    // ],\n],\n\n/*\n|--------------------------------------------------------------------------\n| Resetting Passwords\n|--------------------------------------------------------------------------\n|\n| Here you may set the options for resetting passwords including the view\n| that is your password reset e-mail. You may also set the name of the\n| table that maintains all of the reset tokens for your application.\n|\n| You may specify multiple password reset configurations if you have more\n| than one user table or model in the application and you want to have\n| separate password reset settings based on the specific user types.\n|\n| The expire time is the number of minutes that the reset token should be\n| considered valid. This security feature keeps tokens short-lived so\n| they have less time to be guessed. You may change this as needed.\n|\n*/\n\n\'passwords\' => [\n    \'users\' => [\n        \'provider\' => \'users\',\n        \'email\' => \'auth.emails.password\',\n        \'table\' => \'password_resets\',\n        \'expire\' => 60,\n    ],\n    \'companies\' => [\n        \'provider\' => \'companies\',\n        \'email\' => \'business.auth.emails.password\',\n        \'table\' => \'company_password_resets\',\n        \'expire\' => 60,\n    ],\n],\n\n];\n
Run Code Online (Sandbox Code Playgroud)\n\n

也许\xc2\xb4s是一个简单的错误..我希望有人可以帮助我。谢谢。

\n

小智 7

在您的PasswordResetLinkController 上,替换

Password::sendResetLink( ...

Password::broker('companies')->sendResetLink( ...

在 NewPasswordController 上,替换

Password::reset( ...

Password::broker('companies')->reset( ...