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 c09de6a commit 0ffabf6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion 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,10 +128,18 @@ 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.',
], Response::HTTP_INTERNAL_SERVER_ERROR);
});
}
}
}

0 comments on commit 0ffabf6

Please sign in to comment.