mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-28 09:14:44 +02:00
Consolidate service providers
This commit is contained in:
parent
dcdfd2cea9
commit
ec38f7567e
@ -2,18 +2,21 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models;
|
||||
use App\Models\Node;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Extensions\Themes\Theme;
|
||||
use App\Models;
|
||||
use App\Models\ApiKey;
|
||||
use App\Models\Node;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@ -60,6 +63,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
->connectTimeout(config('panel.guzzle.connect_timeout'))
|
||||
->baseUrl($node->getConnectionAddress())
|
||||
);
|
||||
|
||||
$this->bootAuth();
|
||||
$this->bootBroadcast();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,6 +82,8 @@ class AppServiceProvider extends ServiceProvider
|
||||
$this->app->singleton('extensions.themes', function () {
|
||||
return new Theme();
|
||||
});
|
||||
|
||||
$this->registerAuth();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,4 +113,26 @@ class AppServiceProvider extends ServiceProvider
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function bootAuth(): void
|
||||
{
|
||||
Sanctum::usePersonalAccessTokenModel(ApiKey::class);
|
||||
}
|
||||
|
||||
public function bootBroadcast(): void
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
/*
|
||||
* Authenticate the user's personal channel...
|
||||
*/
|
||||
Broadcast::channel('App.User.*', function ($user, $userId) {
|
||||
return (int) $user->id === (int) $userId;
|
||||
});
|
||||
}
|
||||
|
||||
public function registerAuth(): void
|
||||
{
|
||||
Sanctum::ignoreMigrations();
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use App\Models\ApiKey;
|
||||
use App\Models\Server;
|
||||
use App\Policies\ServerPolicy;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The model to policy mappings for the application.
|
||||
*/
|
||||
protected $policies = [
|
||||
Server::class => ServerPolicy::class,
|
||||
];
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
Sanctum::usePersonalAccessTokenModel(ApiKey::class);
|
||||
}
|
||||
|
||||
public function register(): void
|
||||
{
|
||||
Sanctum::ignoreMigrations();
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
/*
|
||||
* Authenticate the user's personal channel...
|
||||
*/
|
||||
Broadcast::channel('App.User.*', function ($user, $userId) {
|
||||
return (int) $user->id === (int) $userId;
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user