I used the php artisan make:auth
feature to have a quick build in Reset-Password and Forget-Password option.
When I go to "Forget-Password" and enter the email of an registered user, I get a message that the email is not found. This happend since I have changed my default guard.
How can I fix this? I want to use ForgotEmailController
for the non-default guard, which is related to a specific model. I think that the Controller is not searching the email in the correct DB from the specific guard. But there is no default guard()
method to overwrite in ForgotEmailController
as in ResetPasswordController
.
Since I have not used the default model I needed to use a custom broker:
use Illuminate\Support\Facades\Password;
class ForgotPasswordController extends Controller
{
// ...
// Password Broker for Seller Model
public function broker()
{
return Password::broker('dogs');
}
}
The broker class "dogs" has do be defined in config/auth.php
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
],
'dogs' => [
'provider' => 'dogs',
'table' => 'password_resets',
'expire' => 60,
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'dogs' =>[
'driver' => 'eloquent',
'model' => App\Dogs::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],