|
3 | 3 | namespace Boy132\GenericOIDCProviders\Extensions\OAuth\Schemas; |
4 | 4 |
|
5 | 5 | use App\Extensions\OAuth\Schemas\OAuthSchema; |
| 6 | +use App\Models\User; |
6 | 7 | use Boy132\GenericOIDCProviders\Filament\Admin\Resources\GenericOIDCProviders\Pages\EditGenericOIDCProvider; |
7 | 8 | use Boy132\GenericOIDCProviders\Models\GenericOIDCProvider; |
8 | 9 | use Filament\Infolists\Components\TextEntry; |
9 | 10 | use Filament\Schemas\Components\Wizard\Step; |
| 11 | +use Illuminate\Support\Str; |
| 12 | +use Laravel\Socialite\Contracts\User as OAuthUser; |
10 | 13 | use SocialiteProviders\OIDC\Provider; |
11 | 14 |
|
12 | 15 | final class GenericOIDCProviderSchema extends OAuthSchema |
13 | 16 | { |
14 | | - public function __construct(private GenericOIDCProvider $model) {} |
| 17 | + public function __construct(private readonly GenericOIDCProvider $model) {} |
15 | 18 |
|
16 | 19 | public function getId(): string |
17 | 20 | { |
@@ -72,12 +75,19 @@ public function getHexColor(): ?string |
72 | 75 | return $this->model->display_color; |
73 | 76 | } |
74 | 77 |
|
75 | | - public function shouldCreateMissingUsers(): bool |
| 78 | + public function isEnabled(): bool |
| 79 | + { |
| 80 | + $id = Str::upper($this->getId()); |
| 81 | + |
| 82 | + return env("OAUTH_{$id}_ENABLED", true); |
| 83 | + } |
| 84 | + |
| 85 | + public function shouldCreateMissingUser(OAuthUser $user): bool |
76 | 86 | { |
77 | 87 | return $this->model->create_missing_users; |
78 | 88 | } |
79 | 89 |
|
80 | | - public function shouldLinkMissingUsers(): bool |
| 90 | + public function shouldLinkMissingUser(User $user, OAuthUser $oauthUser): bool |
81 | 91 | { |
82 | 92 | return $this->model->link_missing_users; |
83 | 93 | } |
|
0 commit comments