Skip to content

Commit 0ffabf6

Browse files
committed
hotfix: Unhandled edge cases on unauthenticated users
1 parent c09de6a commit 0ffabf6

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

app/Exceptions/Handler.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ public function register()
109109

110110
if (config('app.debug')) {
111111
$this->renderable(function (Throwable $e) {
112+
if ($e->getMessage() === 'Unauthenticated.') {
113+
return response()->json([
114+
'message' => 'Giriş yapmanız gereklidir.'
115+
], Response::HTTP_UNAUTHORIZED)
116+
->withoutCookie('token')
117+
->withoutCookie('currentUser');
118+
}
119+
112120
return response()->json([
113121
'type' => get_class($e),
114122
'message' => $e->getMessage(),
@@ -120,10 +128,18 @@ public function register()
120128
}
121129

122130
$this->renderable(function (Throwable $e) {
131+
if ($e->getMessage() === 'Unauthenticated.') {
132+
return response()->json([
133+
'message' => 'Giriş yapmanız gereklidir.'
134+
], Response::HTTP_UNAUTHORIZED)
135+
->withoutCookie('token')
136+
->withoutCookie('currentUser');
137+
}
138+
123139
return response()->json([
124140
'type' => get_class($e),
125141
'message' => 'Beklenmeyen bir hata oluştu. Sistem yöneticinize başvurunuz.',
126142
], Response::HTTP_INTERNAL_SERVER_ERROR);
127143
});
128144
}
129-
}
145+
}

0 commit comments

Comments
 (0)