From 842946a7c6b0d11475d8d47a09aefac27fa5555d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Fran=C3=A7a?= Date: Fri, 15 Mar 2024 01:31:16 -0300 Subject: [PATCH] Add verification if telescope is enabled using config helper in other place (#447) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add verification if telescope is enabled using config helper * CS Fixer * chore: fix linter warning * Change Telescope class to CONST and add check telescope enabled in UserProviderAbstract --------- Signed-off-by: Samuel França Co-authored-by: Evan Sims --- src/Guards/AuthenticationGuard.php | 7 ++++++- src/UserProviderAbstract.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Guards/AuthenticationGuard.php b/src/Guards/AuthenticationGuard.php index ceea851..23f8c7a 100644 --- a/src/Guards/AuthenticationGuard.php +++ b/src/Guards/AuthenticationGuard.php @@ -27,6 +27,11 @@ */ final class AuthenticationGuard extends GuardAbstract implements AuthenticationGuardContract { + /** + * @var string + */ + protected const TELESCOPE = '\Laravel\Telescope\Telescope'; + public function find(): ?CredentialEntityContract { if ($this->isImpersonating()) { @@ -283,7 +288,7 @@ public function user(): ?Authenticatable * @var ?Authenticatable $lastResponse */ // @codeCoverageIgnoreStart - if (class_exists('\Laravel\Telescope\Telescope') && true === config('telescope.enabled')) { + if (class_exists(self::TELESCOPE) && true === config('telescope.enabled')) { static $depth = 0; static $lastCalled = null; diff --git a/src/UserProviderAbstract.php b/src/UserProviderAbstract.php index 0712c1a..917feb9 100644 --- a/src/UserProviderAbstract.php +++ b/src/UserProviderAbstract.php @@ -79,7 +79,7 @@ final public function retrieveByCredentials(array $credentials): ?Authenticatabl return $lastResponse; } - if (class_exists('\Laravel\Telescope\Telescope')) { + if (class_exists(self::TELESCOPE) && true === config('telescope.enabled')) { static $depth = 0; static $lastCalled = null;