From 2bee717422613fbc8e1b7162d6def242cec2227d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Mon, 18 May 2020 17:19:33 +0200 Subject: [PATCH] Handle exceptions in case the request doesn't have a user (#274) --- src/Context/LaravelRequestContext.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Context/LaravelRequestContext.php b/src/Context/LaravelRequestContext.php index 0275a9a8..953c6fb4 100644 --- a/src/Context/LaravelRequestContext.php +++ b/src/Context/LaravelRequestContext.php @@ -17,9 +17,13 @@ public function __construct(Request $request) public function getUser(): array { - $user = $this->request->user(); - - if (! $user) { + try { + $user = $this->request->user(); + + if (! $user) { + return []; + } + } catch (\Throwable $e) { return []; }