в auth.php я добавил пользовательскую аутентификацию клиентов:
Код: Выделить всё
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'customers' => [
'driver' => 'jwt',
'provider' => 'customers',
],
],
Код: Выделить всё
providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'customers' => [
'driver' => 'eloquent',
'model' => App\Customer::class,
],
],
Код: Выделить всё
Route::group(['middleware' => 'customers'], function() {
Route::post('login', 'JwtAuth\LoginController@login'); //Had made new auth for JWT
}
Я также пробовал использовать следующий код внутри Controller\JwtAuth\LoginController.php:
Код: Выделить всё
public function login(Request $request)
{
$credentials = $request->only('email', 'password');
$customer = Auth::guard('customers')->attempt($credentials);
try {
// attempt to verify the credentials and create a token for the user
if (!$token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'invalid_credentials'], 401);
}
} catch (JWTException $e) {
// something went wrong whilst attempting to encode the token
return response()->json(['error' => 'could_not_create_token'], 500);
}
// all good so return the token
return response()->json(compact('token'), Response::HTTP_OK);
}
Код: Выделить всё
Auth guard driver [customers] is not defined.
Код: Выделить всё
'api' => [
'throttle:60,1',
'bindings'
],
'customers' => [
'throttle:60:1',
'bindings'
]
Любая помощь/руководство будет очень признательна. Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/425 ... ot-defined
Мобильная версия