diff --git a/src/Issuer.php b/src/Issuer.php index 0d62b4f..875d3dd 100644 --- a/src/Issuer.php +++ b/src/Issuer.php @@ -64,6 +64,11 @@ class Issuer 'root', ]; + public function useSanctum(): bool + { + return $this->useSanctum; + } + /** * @return array */ @@ -250,10 +255,14 @@ public function init(Authenticatable $user): self $config = is_array($config) ? $config : []; if ($user instanceof HasApiTokens || is_callable([$user, 'createToken'])) { - $this->hasSanctum = ! empty($config['sanctum']); + $this->hasSanctum = true; } else { $this->hasSanctum = false; } + + if ($this->hasSanctum && ! empty($config['sanctum'])) { + $this->useSanctum = true; + } // dd([ // '__METHOD__' => __METHOD__, // '$user' => $user->toArray(), @@ -349,6 +358,11 @@ public function authorize(Authenticatable $user): array } else { $tokens = []; } + // dd([ + // '$tokens' => $tokens, + // '$this->useSanctum' => $this->useSanctum, + // '$this->hasSanctum' => $this->hasSanctum, + // ]); return $tokens; } @@ -362,6 +376,9 @@ public function sanctum(Authenticatable $user): array * @var array $config */ $config = config('playground-auth.token'); + // dump([ + // '$config' => $config, + // ]); $this->init($user);