Return empty string when JWT auth failed

This commit is contained in:
Pig Fang 2019-04-26 18:58:12 +08:00
parent 748c275969
commit 1a98e7937d
2 changed files with 6 additions and 1 deletions

View File

@ -259,7 +259,7 @@ class AuthController extends Controller
$token = Auth::guard('jwt')->attempt([
'email' => $request->email,
'password' => $request->password
]);
]) ?: '';
return json(compact('token'));
}

View File

@ -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()