Skip to content

Commit 1ec5c5a

Browse files
committed
Fix for logout
1 parent 28379e7 commit 1ec5c5a

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

app/Http/Controllers/API/Auth/LoginController.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ public function login(AuthRequest $request): JsonResponse
3131
*/
3232
public function logout(): JsonResponse
3333
{
34-
$user = Auth::user();
35-
$user->currentAccessToken()->delete();
34+
if (Auth::check()) {
35+
$user = Auth::user();
36+
37+
$user->tokens()->delete();
3638

37-
return $this->sendResponse([], AuthConstants::LOGOUT);
39+
return $this->sendResponse([], AuthConstants::LOGOUT);
40+
}
41+
42+
return $this->sendError(AuthConstants::UNAUTHORIZED);
3843
}
3944

4045
/**

app/Http/Middleware/Authenticate.php

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77

88
class Authenticate extends Middleware
99
{
10+
/**
11+
* @param [type] $request
12+
* @param array $guards
13+
* @return void
14+
*/
15+
protected function unauthenticated($request, array $guards)
16+
{
17+
}
18+
1019
/**
1120
* Get the path the user should be redirected to when they are not authenticated.
1221
*/

0 commit comments

Comments
 (0)