Skip to content

Commit

Permalink
hotfix: Unhandled edge cases on unauthenticated users
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukanoksuz committed Mar 13, 2024
1 parent 456a900 commit 2446ead
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ public function register()

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

return response()->json([
'type' => get_class($e),
'message' => $e->getMessage(),
Expand All @@ -120,6 +128,14 @@ public function register()
}

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

return response()->json([
'type' => get_class($e),
'message' => 'Beklenmeyen bir hata oluştu. Sistem yöneticinize başvurunuz.',
Expand Down

0 comments on commit 2446ead

Please sign in to comment.