Skip to content

Commit

Permalink
fix: Token logout issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukanoksuz committed Feb 22, 2024
1 parent 760cd85 commit 463313d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Exceptions;

use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
Expand Down Expand Up @@ -98,6 +99,14 @@ public function register()
], Response::HTTP_INTERNAL_SERVER_ERROR);
});

$this->renderable(function (AuthenticationException $e) {
return response()->json([
'message' => 'Giriş yapmanız gereklidir.'
], Response::HTTP_UNAUTHORIZED)
->withoutCookie('token')
->withoutCookie('currentUser');
});

if (config('app.debug')) {
$this->renderable(function (Throwable $e) {
return response()->json([
Expand All @@ -109,6 +118,7 @@ public function register()
], Response::HTTP_INTERNAL_SERVER_ERROR);
});
}

$this->renderable(function (Throwable $e) {
return response()->json([
'type' => get_class($e),
Expand Down

0 comments on commit 463313d

Please sign in to comment.