i have a project for multi-users and one admin. my problem is when forget your password for guard admin. however the user web guard is work fine when i use forget your password. i use mailtrap as A host mail. in admin route looks like
// Password reset process
Route::get('/password/reset', 'AdminForgotPasswordController@showLinkRequestForm')->name('admin.passwordReset');
Route::post('/password/email', 'AdminForgotPasswordController@sendResetLinkEmail')->name('admin.passwordEmail');
Route::get('/password/reset/{token}', 'AdminResetPasswordController@showResetForm')->name('admin.passwordwithtoken');
Route::post('/password/reset', 'AdminResetPasswordController@reset')->name('admin.passwordupdate');
// Password confirmation process
Route::get('/password/confirm', 'AdminConfirmPasswordController@showConfirmForm')->name('password.confirm');
Route::post('/password/confirm', 'AdminConfirmPasswordController@confirm');
in config/auth.php
'guards' => [
'web' => [ // name of guards
'driver' => 'session',
'provider' => 'users', // search in users table
],
'admin' => [ // name of guards
'driver' => 'session',
'provider' => 'admins', // search in admins table
],
'api' => [
'driver' => 'jwt',
'provider' => 'users',
'hash' => false,
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Models\Admin::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| 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' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
'admins' => [
'provider' => 'admins',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => env('PASSWORD_TIMEOUT'), // use in middleware password.confirm
my Controller looks like (AdminResetPasswordController.php)
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Password;
class AdminResetPasswordController extends Controller
{
use ResetsPasswords;
protected $redirectTo = RouteServiceProvider::ADMIN;
public function showResetForm(Request $request, $token = null)
{
return view('admin.passwords.reset')->with(
['token' => $token, 'email' => $request->email]
);
}
// public function reset(Request $request)
// {
// $request->validate($this->rules(), $this->validationErrorMessages());
// // Here we will attempt to reset the user's password. If it is successful we
// // will update the password on an actual user model and persist it to the
// // database. Otherwise we will parse the error and return the response.
// $response = $this->broker()->reset(
// $this->credentials($request),
// function ($user, $password) {
// $this->resetPassword($user, $password);
// }
// );
// // If the password was successfully reset, we will redirect the user back to
// // the application's home authenticated view. If there is an error we can
// // redirect them back to where they came from with their error message.
// return $response == Password::PASSWORD_RESET
// ? $this->sendResetResponse($request, $response)
// : $this->sendResetFailedResponse($request, $response);
// }
protected function guard()
{
return Auth::guard('admin');
}
public function broker()
{
return Password::broker('admins');
}
}
when i request to change password i get the email notification in mailtrap fine, when i click reset password button i go to the page to change my password , when i enter the new password and password confirm and hit enter i get message 509 database connection error connection error
as i said before the user guard web works fine. thank you
storage/logs/to see if there's any information there?/password/resetis supposed to go toAdminResetPasswordController@reset, but your function is commented outadminssetpassword= $2y$10$v/hLY68Xl1v2RNtwclfcpOMz.goH2rmpsKeZ1KD9vafgPAXDc426y,remember_token= q69TJTcKdQ4CYY4upq1t3z4tl9oQsQ7Xs0lXHTx2Fg0c2SnfyV9Y95e85lBq whereid= 1) {"exception":"[object]ResetsPasswordstrait$table->rememberToken();in admin table