mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 12:14:45 +02:00
Don't log duplicated OauthProvider
s during tests (#1015)
* Make sure OauthProviders we only log if not running tests * Dependency inject
This commit is contained in:
parent
d53820bbdc
commit
1e7a901371
@ -4,10 +4,13 @@ namespace App\Extensions\OAuth\Providers;
|
||||
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Illuminate\Foundation\Application;
|
||||
use SocialiteProviders\Authentik\Provider;
|
||||
|
||||
final class AuthentikProvider extends OAuthProvider
|
||||
{
|
||||
public function __construct(protected Application $app) {}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return 'authentik';
|
||||
@ -61,8 +64,8 @@ final class AuthentikProvider extends OAuthProvider
|
||||
return env('OAUTH_AUTHENTIK_DISPLAY_COLOR') ?? '#fd4b2d';
|
||||
}
|
||||
|
||||
public static function register(): self
|
||||
public static function register(Application $app): self
|
||||
{
|
||||
return new self();
|
||||
return new self($app);
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Extensions\OAuth\Providers;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
|
||||
final class CommonProvider extends OAuthProvider
|
||||
{
|
||||
protected function __construct(private string $id, private ?string $providerClass, private ?string $icon, private ?string $hexColor)
|
||||
protected function __construct(protected Application $app, private string $id, private ?string $providerClass, private ?string $icon, private ?string $hexColor)
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
@ -29,8 +31,8 @@ final class CommonProvider extends OAuthProvider
|
||||
return $this->hexColor;
|
||||
}
|
||||
|
||||
public static function register(string $id, ?string $providerClass = null, ?string $icon = null, ?string $hexColor = null): static
|
||||
public static function register(Application $app, string $id, ?string $providerClass = null, ?string $icon = null, ?string $hexColor = null): static
|
||||
{
|
||||
return new self($id, $providerClass, $icon, $hexColor);
|
||||
return new self($app, $id, $providerClass, $icon, $hexColor);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace App\Extensions\OAuth\Providers;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\Str;
|
||||
use SocialiteProviders\Discord\Provider;
|
||||
@ -12,6 +13,8 @@ use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
||||
|
||||
final class DiscordProvider extends OAuthProvider
|
||||
{
|
||||
public function __construct(protected Application $app) {}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return 'discord';
|
||||
@ -51,8 +54,8 @@ final class DiscordProvider extends OAuthProvider
|
||||
return '#5865F2';
|
||||
}
|
||||
|
||||
public static function register(): self
|
||||
public static function register(Application $app): self
|
||||
{
|
||||
return new self();
|
||||
return new self($app);
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,15 @@ namespace App\Extensions\OAuth\Providers;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\Str;
|
||||
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
||||
|
||||
final class GithubProvider extends OAuthProvider
|
||||
{
|
||||
public function __construct(protected Application $app) {}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return 'github';
|
||||
@ -50,8 +53,8 @@ final class GithubProvider extends OAuthProvider
|
||||
return '#4078c0';
|
||||
}
|
||||
|
||||
public static function register(): self
|
||||
public static function register(Application $app): self
|
||||
{
|
||||
return new self();
|
||||
return new self($app);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace App\Extensions\OAuth\Providers;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Str;
|
||||
use SocialiteProviders\Manager\SocialiteWasCalled;
|
||||
@ -17,10 +18,12 @@ abstract class OAuthProvider
|
||||
return $id ? static::$providers[$id] : static::$providers;
|
||||
}
|
||||
|
||||
protected function __construct()
|
||||
protected function __construct(protected Application $app)
|
||||
{
|
||||
if (array_key_exists($this->getId(), static::$providers)) {
|
||||
logger()->warning("Tried to create duplicate OAuth provider with id '{$this->getId()}'");
|
||||
if (!$this->app->runningUnitTests()) {
|
||||
logger()->warning("Tried to create duplicate OAuth provider with id '{$this->getId()}'");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -5,11 +5,14 @@ namespace App\Extensions\OAuth\Providers;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use SocialiteProviders\Steam\Provider;
|
||||
|
||||
final class SteamProvider extends OAuthProvider
|
||||
{
|
||||
public function __construct(protected Application $app) {}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return 'steam';
|
||||
@ -67,8 +70,8 @@ final class SteamProvider extends OAuthProvider
|
||||
return '#00adee';
|
||||
}
|
||||
|
||||
public static function register(): self
|
||||
public static function register(Application $app): self
|
||||
{
|
||||
return new self();
|
||||
return new self($app);
|
||||
}
|
||||
}
|
||||
|
@ -86,19 +86,19 @@ class AppServiceProvider extends ServiceProvider
|
||||
Scramble::registerApi('remote', ['api_path' => 'api/remote', 'info' => ['version' => '1.0']])->afterOpenApiGenerated($bearerTokens);
|
||||
|
||||
// Default OAuth providers included with Socialite
|
||||
CommonProvider::register('facebook', null, 'tabler-brand-facebook-f', '#1877f2');
|
||||
CommonProvider::register('x', null, 'tabler-brand-x-f', '#1da1f2');
|
||||
CommonProvider::register('linkedin', null, 'tabler-brand-linkedin-f', '#0a66c2');
|
||||
CommonProvider::register('google', null, 'tabler-brand-google-f', '#4285f4');
|
||||
GithubProvider::register();
|
||||
CommonProvider::register('gitlab', null, 'tabler-brand-gitlab', '#fca326');
|
||||
CommonProvider::register('bitbucket', null, 'tabler-brand-bitbucket-f', '#205081');
|
||||
CommonProvider::register('slack', null, 'tabler-brand-slack', '#6ecadc');
|
||||
CommonProvider::register($app, 'facebook', null, 'tabler-brand-facebook-f', '#1877f2');
|
||||
CommonProvider::register($app, 'x', null, 'tabler-brand-x-f', '#1da1f2');
|
||||
CommonProvider::register($app, 'linkedin', null, 'tabler-brand-linkedin-f', '#0a66c2');
|
||||
CommonProvider::register($app, 'google', null, 'tabler-brand-google-f', '#4285f4');
|
||||
GithubProvider::register($app);
|
||||
CommonProvider::register($app, 'gitlab', null, 'tabler-brand-gitlab', '#fca326');
|
||||
CommonProvider::register($app, 'bitbucket', null, 'tabler-brand-bitbucket-f', '#205081');
|
||||
CommonProvider::register($app, 'slack', null, 'tabler-brand-slack', '#6ecadc');
|
||||
|
||||
// Additional OAuth providers from socialiteproviders.com
|
||||
AuthentikProvider::register();
|
||||
DiscordProvider::register();
|
||||
SteamProvider::register();
|
||||
AuthentikProvider::register($app);
|
||||
DiscordProvider::register($app);
|
||||
SteamProvider::register($app);
|
||||
|
||||
FilamentColor::register([
|
||||
'danger' => Color::Red,
|
||||
|
Loading…
x
Reference in New Issue
Block a user