I have error when do login in api by jwt ..when i do register its good will but in login display error
InvalidArgumentException: Auth guard [customers] is not defined. in file C:\Users\Ahmed\Desktop\project web\laravel_pro\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php on line 84
this is the controller
public function login(Request $request){
$credentials = $request->only('email', 'password');
if (Auth::guard('customer')->attempt($credentials))
{
$user= JWTAuth::guard('customer')->user();
$jwt = JwtAuth::generateToken($user);
return response()->json(compact('jwt'));
}else{
return response()->json(['error' => 'invalid_credentials'], 400);
}
this is the api route
Route::post('login','UserController@login');
this is the auth.php
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'customer'=>[
'driver' => 'token',
'provider'=> 'customers',
]
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'customers' => [
'driver' => 'eloquent',
'model' => App\Customer::class,
],
please any body help my to Solution..Thank you
php artisan config:clear
orphp artisan config:cache
– Sehdevtoken
tosession
'driver' => 'session',
After that run againphp artisan cache:clear php artisan config:cache
– Sehdev