mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 14:56:51 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			54 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Extensions\OAuth\Schemas;
 | 
						|
 | 
						|
use Filament\Forms\Components\Placeholder;
 | 
						|
use Filament\Forms\Components\TextInput;
 | 
						|
use Filament\Forms\Components\Wizard\Step;
 | 
						|
use Illuminate\Support\Facades\Blade;
 | 
						|
use Illuminate\Support\HtmlString;
 | 
						|
use SocialiteProviders\Discord\Provider;
 | 
						|
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
 | 
						|
 | 
						|
final class DiscordSchema extends OAuthSchema
 | 
						|
{
 | 
						|
    public function getId(): string
 | 
						|
    {
 | 
						|
        return 'discord';
 | 
						|
    }
 | 
						|
 | 
						|
    public function getSocialiteProvider(): string
 | 
						|
    {
 | 
						|
        return Provider::class;
 | 
						|
    }
 | 
						|
 | 
						|
    public function getSetupSteps(): array
 | 
						|
    {
 | 
						|
        return array_merge([
 | 
						|
            Step::make('Register new Discord OAuth App')
 | 
						|
                ->schema([
 | 
						|
                    Placeholder::make('')
 | 
						|
                        ->content(new HtmlString(Blade::render('<p>Visit the <x-filament::link href="https://discord.com/developers/applications" target="_blank">Discord Developer Portal</x-filament::link> and click on <b>New Application</b>. Enter a <b>Name</b> (e.g. your panel name) and click on <b>Create</b>.</p><p>Copy the <b>Client ID</b> and the <b>Client Secret</b> from the OAuth2 tab, you will need them in the final step.</p>'))),
 | 
						|
                    Placeholder::make('')
 | 
						|
                        ->content(new HtmlString('<p>Under <b>Redirects</b> add the below URL.</p>')),
 | 
						|
                    TextInput::make('_noenv_callback')
 | 
						|
                        ->label('Redirect URL')
 | 
						|
                        ->dehydrated()
 | 
						|
                        ->disabled()
 | 
						|
                        ->hintAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
 | 
						|
                        ->formatStateUsing(fn () => url('/auth/oauth/callback/discord')),
 | 
						|
                ]),
 | 
						|
        ], parent::getSetupSteps());
 | 
						|
    }
 | 
						|
 | 
						|
    public function getIcon(): string
 | 
						|
    {
 | 
						|
        return 'tabler-brand-discord-f';
 | 
						|
    }
 | 
						|
 | 
						|
    public function getHexColor(): string
 | 
						|
    {
 | 
						|
        return '#5865F2';
 | 
						|
    }
 | 
						|
}
 |