Skip to content

Commit

Permalink
Add verification if telescope is enabled using config helper in other…
Browse files Browse the repository at this point in the history
… place (#447)

* 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 <[email protected]>
Co-authored-by: Evan Sims <[email protected]>
  • Loading branch information
samuelhgf and evansims authored Mar 15, 2024
1 parent 9ff4aa7 commit 842946a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Guards/AuthenticationGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/UserProviderAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 842946a

Please sign in to comment.