mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 08:44:46 +02:00
Use config helper instead
This commit is contained in:
parent
b11810588a
commit
d9cfb62a12
@ -4,7 +4,6 @@ namespace App\Console\Commands\Environment;
|
|||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use App\Traits\Commands\EnvironmentWriterTrait;
|
use App\Traits\Commands\EnvironmentWriterTrait;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
||||||
|
|
||||||
class EmailSettingsCommand extends Command
|
class EmailSettingsCommand extends Command
|
||||||
{
|
{
|
||||||
@ -25,14 +24,6 @@ class EmailSettingsCommand extends Command
|
|||||||
|
|
||||||
protected array $variables = [];
|
protected array $variables = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* EmailSettingsCommand constructor.
|
|
||||||
*/
|
|
||||||
public function __construct(private ConfigRepository $config)
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle command execution.
|
* Handle command execution.
|
||||||
*
|
*
|
||||||
@ -49,7 +40,7 @@ class EmailSettingsCommand extends Command
|
|||||||
'mandrill' => 'Mandrill Transactional Email',
|
'mandrill' => 'Mandrill Transactional Email',
|
||||||
'postmark' => 'Postmark Transactional Email',
|
'postmark' => 'Postmark Transactional Email',
|
||||||
],
|
],
|
||||||
$this->config->get('mail.default', 'smtp')
|
config('mail.default', 'smtp')
|
||||||
);
|
);
|
||||||
|
|
||||||
$method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables';
|
$method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables';
|
||||||
@ -59,12 +50,12 @@ class EmailSettingsCommand extends Command
|
|||||||
|
|
||||||
$this->variables['MAIL_FROM_ADDRESS'] = $this->option('email') ?? $this->ask(
|
$this->variables['MAIL_FROM_ADDRESS'] = $this->option('email') ?? $this->ask(
|
||||||
trans('command/messages.environment.mail.ask_mail_from'),
|
trans('command/messages.environment.mail.ask_mail_from'),
|
||||||
$this->config->get('mail.from.address')
|
config('mail.from.address')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->variables['MAIL_FROM_NAME'] = $this->option('from') ?? $this->ask(
|
$this->variables['MAIL_FROM_NAME'] = $this->option('from') ?? $this->ask(
|
||||||
trans('command/messages.environment.mail.ask_mail_name'),
|
trans('command/messages.environment.mail.ask_mail_name'),
|
||||||
$this->config->get('mail.from.name')
|
config('mail.from.name')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->writeToEnvironment($this->variables);
|
$this->writeToEnvironment($this->variables);
|
||||||
@ -80,17 +71,17 @@ class EmailSettingsCommand extends Command
|
|||||||
{
|
{
|
||||||
$this->variables['MAIL_HOST'] = $this->option('host') ?? $this->ask(
|
$this->variables['MAIL_HOST'] = $this->option('host') ?? $this->ask(
|
||||||
trans('command/messages.environment.mail.ask_smtp_host'),
|
trans('command/messages.environment.mail.ask_smtp_host'),
|
||||||
$this->config->get('mail.mailers.smtp.host')
|
config('mail.mailers.smtp.host')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->variables['MAIL_PORT'] = $this->option('port') ?? $this->ask(
|
$this->variables['MAIL_PORT'] = $this->option('port') ?? $this->ask(
|
||||||
trans('command/messages.environment.mail.ask_smtp_port'),
|
trans('command/messages.environment.mail.ask_smtp_port'),
|
||||||
$this->config->get('mail.mailers.smtp.port')
|
config('mail.mailers.smtp.port')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->variables['MAIL_USERNAME'] = $this->option('username') ?? $this->ask(
|
$this->variables['MAIL_USERNAME'] = $this->option('username') ?? $this->ask(
|
||||||
trans('command/messages.environment.mail.ask_smtp_username'),
|
trans('command/messages.environment.mail.ask_smtp_username'),
|
||||||
$this->config->get('mail.mailers.smtp.username')
|
config('mail.mailers.smtp.username')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->variables['MAIL_PASSWORD'] = $this->option('password') ?? $this->secret(
|
$this->variables['MAIL_PASSWORD'] = $this->option('password') ?? $this->secret(
|
||||||
@ -100,7 +91,7 @@ class EmailSettingsCommand extends Command
|
|||||||
$this->variables['MAIL_ENCRYPTION'] = $this->option('encryption') ?? $this->choice(
|
$this->variables['MAIL_ENCRYPTION'] = $this->option('encryption') ?? $this->choice(
|
||||||
trans('command/messages.environment.mail.ask_encryption'),
|
trans('command/messages.environment.mail.ask_encryption'),
|
||||||
['tls' => 'TLS', 'ssl' => 'SSL', '' => 'None'],
|
['tls' => 'TLS', 'ssl' => 'SSL', '' => 'None'],
|
||||||
$this->config->get('mail.mailers.smtp.encryption', 'tls')
|
config('mail.mailers.smtp.encryption', 'tls')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,17 +102,17 @@ class EmailSettingsCommand extends Command
|
|||||||
{
|
{
|
||||||
$this->variables['MAILGUN_DOMAIN'] = $this->option('host') ?? $this->ask(
|
$this->variables['MAILGUN_DOMAIN'] = $this->option('host') ?? $this->ask(
|
||||||
trans('command/messages.environment.mail.ask_mailgun_domain'),
|
trans('command/messages.environment.mail.ask_mailgun_domain'),
|
||||||
$this->config->get('services.mailgun.domain')
|
config('services.mailgun.domain')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->variables['MAILGUN_SECRET'] = $this->option('password') ?? $this->ask(
|
$this->variables['MAILGUN_SECRET'] = $this->option('password') ?? $this->ask(
|
||||||
trans('command/messages.environment.mail.ask_mailgun_secret'),
|
trans('command/messages.environment.mail.ask_mailgun_secret'),
|
||||||
$this->config->get('services.mailgun.secret')
|
config('services.mailgun.secret')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->variables['MAILGUN_ENDPOINT'] = $this->option('endpoint') ?? $this->ask(
|
$this->variables['MAILGUN_ENDPOINT'] = $this->option('endpoint') ?? $this->ask(
|
||||||
trans('command/messages.environment.mail.ask_mailgun_endpoint'),
|
trans('command/messages.environment.mail.ask_mailgun_endpoint'),
|
||||||
$this->config->get('services.mailgun.endpoint')
|
config('services.mailgun.endpoint')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +123,7 @@ class EmailSettingsCommand extends Command
|
|||||||
{
|
{
|
||||||
$this->variables['MANDRILL_SECRET'] = $this->option('password') ?? $this->ask(
|
$this->variables['MANDRILL_SECRET'] = $this->option('password') ?? $this->ask(
|
||||||
trans('command/messages.environment.mail.ask_mandrill_secret'),
|
trans('command/messages.environment.mail.ask_mandrill_secret'),
|
||||||
$this->config->get('services.mandrill.secret')
|
config('services.mandrill.secret')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +137,7 @@ class EmailSettingsCommand extends Command
|
|||||||
$this->variables['MAIL_PORT'] = 587;
|
$this->variables['MAIL_PORT'] = 587;
|
||||||
$this->variables['MAIL_USERNAME'] = $this->variables['MAIL_PASSWORD'] = $this->option('username') ?? $this->ask(
|
$this->variables['MAIL_USERNAME'] = $this->variables['MAIL_PASSWORD'] = $this->option('username') ?? $this->ask(
|
||||||
trans('command/messages.environment.mail.ask_postmark_username'),
|
trans('command/messages.environment.mail.ask_postmark_username'),
|
||||||
$this->config->get('mail.username')
|
config('mail.username')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use App\Services\Helpers\SoftwareVersionService;
|
use App\Services\Helpers\SoftwareVersionService;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
||||||
|
|
||||||
class InfoCommand extends Command
|
class InfoCommand extends Command
|
||||||
{
|
{
|
||||||
@ -15,7 +14,7 @@ class InfoCommand extends Command
|
|||||||
/**
|
/**
|
||||||
* VersionCommand constructor.
|
* VersionCommand constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(private ConfigRepository $config, private SoftwareVersionService $versionService)
|
public function __construct(private SoftwareVersionService $versionService)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
@ -27,47 +26,47 @@ class InfoCommand extends Command
|
|||||||
{
|
{
|
||||||
$this->output->title('Version Information');
|
$this->output->title('Version Information');
|
||||||
$this->table([], [
|
$this->table([], [
|
||||||
['Panel Version', $this->config->get('app.version')],
|
['Panel Version', config('app.version')],
|
||||||
['Latest Version', $this->versionService->getPanel()],
|
['Latest Version', $this->versionService->getPanel()],
|
||||||
['Up-to-Date', $this->versionService->isLatestPanel() ? 'Yes' : $this->formatText('No', 'bg=red')],
|
['Up-to-Date', $this->versionService->isLatestPanel() ? 'Yes' : $this->formatText('No', 'bg=red')],
|
||||||
['Unique Identifier', $this->config->get('panel.service.author')],
|
['Unique Identifier', config('panel.service.author')],
|
||||||
], 'compact');
|
], 'compact');
|
||||||
|
|
||||||
$this->output->title('Application Configuration');
|
$this->output->title('Application Configuration');
|
||||||
$this->table([], [
|
$this->table([], [
|
||||||
['Environment', $this->formatText($this->config->get('app.env'), $this->config->get('app.env') === 'production' ?: 'bg=red')],
|
['Environment', $this->formatText(config('app.env'), config('app.env') === 'production' ?: 'bg=red')],
|
||||||
['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', !$this->config->get('app.debug') ?: 'bg=red')],
|
['Debug Mode', $this->formatText(config('app.debug') ? 'Yes' : 'No', !config('app.debug') ?: 'bg=red')],
|
||||||
['Installation URL', $this->config->get('app.url')],
|
['Installation URL', config('app.url')],
|
||||||
['Installation Directory', base_path()],
|
['Installation Directory', base_path()],
|
||||||
['Timezone', $this->config->get('app.timezone')],
|
['Timezone', config('app.timezone')],
|
||||||
['Cache Driver', $this->config->get('cache.default')],
|
['Cache Driver', config('cache.default')],
|
||||||
['Queue Driver', $this->config->get('queue.default')],
|
['Queue Driver', config('queue.default')],
|
||||||
['Session Driver', $this->config->get('session.driver')],
|
['Session Driver', config('session.driver')],
|
||||||
['Filesystem Driver', $this->config->get('filesystems.default')],
|
['Filesystem Driver', config('filesystems.default')],
|
||||||
['Default Theme', $this->config->get('themes.active')],
|
['Default Theme', config('themes.active')],
|
||||||
['Proxies', $this->config->get('trustedproxies.proxies')],
|
['Proxies', config('trustedproxies.proxies')],
|
||||||
], 'compact');
|
], 'compact');
|
||||||
|
|
||||||
$this->output->title('Database Configuration');
|
$this->output->title('Database Configuration');
|
||||||
$driver = $this->config->get('database.default');
|
$driver = config('database.default');
|
||||||
$this->table([], [
|
$this->table([], [
|
||||||
['Driver', $driver],
|
['Driver', $driver],
|
||||||
['Host', $this->config->get("database.connections.$driver.host")],
|
['Host', config("database.connections.$driver.host")],
|
||||||
['Port', $this->config->get("database.connections.$driver.port")],
|
['Port', config("database.connections.$driver.port")],
|
||||||
['Database', $this->config->get("database.connections.$driver.database")],
|
['Database', config("database.connections.$driver.database")],
|
||||||
['Username', $this->config->get("database.connections.$driver.username")],
|
['Username', config("database.connections.$driver.username")],
|
||||||
], 'compact');
|
], 'compact');
|
||||||
|
|
||||||
// TODO: Update this to handle other mail drivers
|
// TODO: Update this to handle other mail drivers
|
||||||
$this->output->title('Email Configuration');
|
$this->output->title('Email Configuration');
|
||||||
$this->table([], [
|
$this->table([], [
|
||||||
['Driver', $this->config->get('mail.default')],
|
['Driver', config('mail.default')],
|
||||||
['Host', $this->config->get('mail.mailers.smtp.host')],
|
['Host', config('mail.mailers.smtp.host')],
|
||||||
['Port', $this->config->get('mail.mailers.smtp.port')],
|
['Port', config('mail.mailers.smtp.port')],
|
||||||
['Username', $this->config->get('mail.mailers.smtp.username')],
|
['Username', config('mail.mailers.smtp.username')],
|
||||||
['From Address', $this->config->get('mail.from.address')],
|
['From Address', config('mail.from.address')],
|
||||||
['From Name', $this->config->get('mail.from.name')],
|
['From Name', config('mail.from.name')],
|
||||||
['Encryption', $this->config->get('mail.mailers.smtp.encryption')],
|
['Encryption', config('mail.mailers.smtp.encryption')],
|
||||||
], 'compact');
|
], 'compact');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,12 +11,9 @@ use Illuminate\Foundation\Application;
|
|||||||
use League\Flysystem\FilesystemAdapter;
|
use League\Flysystem\FilesystemAdapter;
|
||||||
use App\Extensions\Filesystem\S3Filesystem;
|
use App\Extensions\Filesystem\S3Filesystem;
|
||||||
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
|
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
||||||
|
|
||||||
class BackupManager
|
class BackupManager
|
||||||
{
|
{
|
||||||
protected ConfigRepository $config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The array of resolved backup drivers.
|
* The array of resolved backup drivers.
|
||||||
*/
|
*/
|
||||||
@ -32,7 +29,6 @@ class BackupManager
|
|||||||
*/
|
*/
|
||||||
public function __construct(protected Application $app)
|
public function __construct(protected Application $app)
|
||||||
{
|
{
|
||||||
$this->config = $app->make(ConfigRepository::class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,7 +123,7 @@ class BackupManager
|
|||||||
*/
|
*/
|
||||||
protected function getConfig(string $name): array
|
protected function getConfig(string $name): array
|
||||||
{
|
{
|
||||||
return $this->config->get("backups.disks.$name") ?: [];
|
return config("backups.disks.$name") ?: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,7 +131,7 @@ class BackupManager
|
|||||||
*/
|
*/
|
||||||
public function getDefaultAdapter(): string
|
public function getDefaultAdapter(): string
|
||||||
{
|
{
|
||||||
return $this->config->get('backups.default');
|
return config('backups.default');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,7 +139,7 @@ class BackupManager
|
|||||||
*/
|
*/
|
||||||
public function setDefaultAdapter(string $name): void
|
public function setDefaultAdapter(string $name): void
|
||||||
{
|
{
|
||||||
$this->config->set('backups.default', $name);
|
config()->set('backups.default', $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -163,7 +159,7 @@ class BackupManager
|
|||||||
/**
|
/**
|
||||||
* Register a custom adapter creator closure.
|
* Register a custom adapter creator closure.
|
||||||
*/
|
*/
|
||||||
public function extend(string $adapter, \Closure $callback): self
|
public function extend(string $adapter, Closure $callback): self
|
||||||
{
|
{
|
||||||
$this->customCreators[$adapter] = $callback;
|
$this->customCreators[$adapter] = $callback;
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ use App\Services\Databases\DatabasePasswordService;
|
|||||||
use App\Services\Servers\DetailsModificationService;
|
use App\Services\Servers\DetailsModificationService;
|
||||||
use App\Services\Servers\StartupModificationService;
|
use App\Services\Servers\StartupModificationService;
|
||||||
use App\Services\Databases\DatabaseManagementService;
|
use App\Services\Databases\DatabaseManagementService;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
||||||
use App\Services\Servers\ServerConfigurationStructureService;
|
use App\Services\Servers\ServerConfigurationStructureService;
|
||||||
use App\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest;
|
use App\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest;
|
||||||
|
|
||||||
@ -36,7 +35,6 @@ class ServersController extends Controller
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
protected AlertsMessageBag $alert,
|
protected AlertsMessageBag $alert,
|
||||||
protected BuildModificationService $buildModificationService,
|
protected BuildModificationService $buildModificationService,
|
||||||
protected ConfigRepository $config,
|
|
||||||
protected DaemonServerRepository $daemonServerRepository,
|
protected DaemonServerRepository $daemonServerRepository,
|
||||||
protected DatabaseManagementService $databaseManagementService,
|
protected DatabaseManagementService $databaseManagementService,
|
||||||
protected DatabasePasswordService $databasePasswordService,
|
protected DatabasePasswordService $databasePasswordService,
|
||||||
|
@ -8,7 +8,6 @@ use Illuminate\Http\RedirectResponse;
|
|||||||
use Prologue\Alerts\AlertsMessageBag;
|
use Prologue\Alerts\AlertsMessageBag;
|
||||||
use Illuminate\Contracts\Console\Kernel;
|
use Illuminate\Contracts\Console\Kernel;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
||||||
use App\Http\Requests\Admin\Settings\AdvancedSettingsFormRequest;
|
use App\Http\Requests\Admin\Settings\AdvancedSettingsFormRequest;
|
||||||
|
|
||||||
class AdvancedController extends Controller
|
class AdvancedController extends Controller
|
||||||
@ -18,7 +17,6 @@ class AdvancedController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private AlertsMessageBag $alert,
|
private AlertsMessageBag $alert,
|
||||||
private ConfigRepository $config,
|
|
||||||
private Kernel $kernel,
|
private Kernel $kernel,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
@ -30,8 +28,8 @@ class AdvancedController extends Controller
|
|||||||
{
|
{
|
||||||
$showRecaptchaWarning = false;
|
$showRecaptchaWarning = false;
|
||||||
if (
|
if (
|
||||||
$this->config->get('recaptcha._shipped_secret_key') === $this->config->get('recaptcha.secret_key')
|
config('recaptcha._shipped_secret_key') === config('recaptcha.secret_key')
|
||||||
|| $this->config->get('recaptcha._shipped_website_key') === $this->config->get('recaptcha.website_key')
|
|| config('recaptcha._shipped_website_key') === config('recaptcha.website_key')
|
||||||
) {
|
) {
|
||||||
$showRecaptchaWarning = true;
|
$showRecaptchaWarning = true;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ use App\Exceptions\DisplayException;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Contracts\Encryption\Encrypter;
|
use Illuminate\Contracts\Encryption\Encrypter;
|
||||||
use App\Providers\SettingsServiceProvider;
|
use App\Providers\SettingsServiceProvider;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
||||||
use App\Http\Requests\Admin\Settings\MailSettingsFormRequest;
|
use App\Http\Requests\Admin\Settings\MailSettingsFormRequest;
|
||||||
|
|
||||||
class MailController extends Controller
|
class MailController extends Controller
|
||||||
@ -22,7 +21,6 @@ class MailController extends Controller
|
|||||||
* MailController constructor.
|
* MailController constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private ConfigRepository $config,
|
|
||||||
private Encrypter $encrypter,
|
private Encrypter $encrypter,
|
||||||
private Kernel $kernel,
|
private Kernel $kernel,
|
||||||
) {
|
) {
|
||||||
@ -35,7 +33,7 @@ class MailController extends Controller
|
|||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return view('admin.settings.mail', [
|
return view('admin.settings.mail', [
|
||||||
'disabled' => $this->config->get('mail.default') !== 'smtp',
|
'disabled' => config('mail.default') !== 'smtp',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +45,7 @@ class MailController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(MailSettingsFormRequest $request): Response
|
public function update(MailSettingsFormRequest $request): Response
|
||||||
{
|
{
|
||||||
if ($this->config->get('mail.default') !== 'smtp') {
|
if (config('mail.default') !== 'smtp') {
|
||||||
throw new DisplayException('This feature is only available if SMTP is the selected email driver for the Panel.');
|
throw new DisplayException('This feature is only available if SMTP is the selected email driver for the Panel.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ use GuzzleHttp\Client;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use App\Events\Auth\FailedCaptcha;
|
use App\Events\Auth\FailedCaptcha;
|
||||||
use Illuminate\Contracts\Config\Repository;
|
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ class VerifyReCaptcha
|
|||||||
/**
|
/**
|
||||||
* VerifyReCaptcha constructor.
|
* VerifyReCaptcha constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(private Dispatcher $dispatcher, private Repository $config)
|
public function __construct(private Dispatcher $dispatcher)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,15 +23,15 @@ class VerifyReCaptcha
|
|||||||
*/
|
*/
|
||||||
public function handle(Request $request, \Closure $next): mixed
|
public function handle(Request $request, \Closure $next): mixed
|
||||||
{
|
{
|
||||||
if (!$this->config->get('recaptcha.enabled')) {
|
if (!config('recaptcha.enabled')) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->filled('g-recaptcha-response')) {
|
if ($request->filled('g-recaptcha-response')) {
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
$res = $client->post($this->config->get('recaptcha.domain'), [
|
$res = $client->post(config('recaptcha.domain'), [
|
||||||
'form_params' => [
|
'form_params' => [
|
||||||
'secret' => $this->config->get('recaptcha.secret_key'),
|
'secret' => config('recaptcha.secret_key'),
|
||||||
'response' => $request->input('g-recaptcha-response'),
|
'response' => $request->input('g-recaptcha-response'),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
@ -40,7 +39,7 @@ class VerifyReCaptcha
|
|||||||
if ($res->getStatusCode() === 200) {
|
if ($res->getStatusCode() === 200) {
|
||||||
$result = json_decode($res->getBody());
|
$result = json_decode($res->getBody());
|
||||||
|
|
||||||
if ($result->success && (!$this->config->get('recaptcha.verify_domain') || $this->isResponseVerified($result, $request))) {
|
if ($result->success && (!config('recaptcha.verify_domain') || $this->isResponseVerified($result, $request))) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +60,7 @@ class VerifyReCaptcha
|
|||||||
*/
|
*/
|
||||||
private function isResponseVerified(\stdClass $result, Request $request): bool
|
private function isResponseVerified(\stdClass $result, Request $request): bool
|
||||||
{
|
{
|
||||||
if (!$this->config->get('recaptcha.verify_domain')) {
|
if (!config('recaptcha.verify_domain')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,18 +4,10 @@ namespace App\Services\Eggs;
|
|||||||
|
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
use App\Models\Egg;
|
use App\Models\Egg;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
||||||
use App\Exceptions\Service\Egg\NoParentConfigurationFoundException;
|
use App\Exceptions\Service\Egg\NoParentConfigurationFoundException;
|
||||||
|
|
||||||
class EggCreationService
|
class EggCreationService
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* EggCreationService constructor.
|
|
||||||
*/
|
|
||||||
public function __construct(private ConfigRepository $config)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new egg.
|
* Create a new egg.
|
||||||
*
|
*
|
||||||
@ -32,7 +24,7 @@ class EggCreationService
|
|||||||
|
|
||||||
return Egg::query()->create(array_merge($data, [
|
return Egg::query()->create(array_merge($data, [
|
||||||
'uuid' => Uuid::uuid4()->toString(),
|
'uuid' => Uuid::uuid4()->toString(),
|
||||||
'author' => $this->config->get('panel.service.author'),
|
'author' => config('panel.service.author'),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ namespace App\Services\Users;
|
|||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Contracts\Encryption\Encrypter;
|
use Illuminate\Contracts\Encryption\Encrypter;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
||||||
|
|
||||||
class TwoFactorSetupService
|
class TwoFactorSetupService
|
||||||
{
|
{
|
||||||
@ -14,7 +13,6 @@ class TwoFactorSetupService
|
|||||||
* TwoFactorSetupService constructor.
|
* TwoFactorSetupService constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private ConfigRepository $config,
|
|
||||||
private Encrypter $encrypter,
|
private Encrypter $encrypter,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
@ -30,7 +28,7 @@ class TwoFactorSetupService
|
|||||||
{
|
{
|
||||||
$secret = '';
|
$secret = '';
|
||||||
try {
|
try {
|
||||||
for ($i = 0; $i < $this->config->get('panel.auth.2fa.bytes', 16); $i++) {
|
for ($i = 0; $i < config('panel.auth.2fa.bytes', 16); $i++) {
|
||||||
$secret .= substr(self::VALID_BASE32_CHARACTERS, random_int(0, 31), 1);
|
$secret .= substr(self::VALID_BASE32_CHARACTERS, random_int(0, 31), 1);
|
||||||
}
|
}
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
@ -40,7 +38,7 @@ class TwoFactorSetupService
|
|||||||
$user->totp_secret = $this->encrypter->encrypt($secret);
|
$user->totp_secret = $this->encrypter->encrypt($secret);
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$company = urlencode(preg_replace('/\s/', '', $this->config->get('app.name')));
|
$company = urlencode(preg_replace('/\s/', '', config('app.name')));
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'image_url_data' => sprintf(
|
'image_url_data' => sprintf(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user