diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index f444bd43..7744a9d6 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -259,7 +259,7 @@ class AuthController extends Controller $token = Auth::guard('jwt')->attempt([ 'email' => $request->email, 'password' => $request->password - ]); + ]) ?: ''; return json(compact('token')); } diff --git a/tests/AuthControllerTest.php b/tests/AuthControllerTest.php index 3c491d6e..92e74c24 100644 --- a/tests/AuthControllerTest.php +++ b/tests/AuthControllerTest.php @@ -550,6 +550,11 @@ class AuthControllerTest extends TestCase 'password' => '12345678' ])->decodeResponseJson('token'); $this->assertTrue(is_string($token)); + + $this->postJson('/api/auth/login', [ + 'email' => $user->email, + 'password' => '123456789' + ])->assertJson(['token' => '']); } public function testApiLogout()