Add imports for facades

This commit is contained in:
James Cole
2025-02-23 12:47:04 +01:00
parent 0086a0ddc8
commit f7ad9c56c8
43 changed files with 132 additions and 94 deletions

View File

@@ -28,6 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
class CreatesFirstUser extends Command
{
@@ -61,11 +62,11 @@ class CreatesFirstUser extends Command
'email' => $this->argument('email'),
'role' => 'owner',
];
$password = \Str::random(24);
$password = Str::random(24);
$user = $this->repository->store($data);
$user->password = Hash::make($password);
$user->save();
$user->setRememberToken(\Str::random(60));
$user->setRememberToken(Str::random(60));
$this->friendlyInfo(sprintf('Created new admin user (ID #%d) with email address "%s" and password "%s".', $user->id, $user->email, $password));
$this->friendlyWarning('Change this password.');

View File

@@ -28,6 +28,8 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\Attachment;
use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Storage;
class ScansAttachments extends Command
{
@@ -43,7 +45,7 @@ class ScansAttachments extends Command
public function handle(): int
{
$attachments = Attachment::get();
$disk = \Storage::disk('upload');
$disk = Storage::disk('upload');
/** @var Attachment $attachment */
foreach ($attachments as $attachment) {
@@ -56,7 +58,7 @@ class ScansAttachments extends Command
}
try {
$decryptedContent = \Crypt::decrypt($encryptedContent); // verified
$decryptedContent = Crypt::decrypt($encryptedContent); // verified
} catch (DecryptException $e) {
app('log')->error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
$decryptedContent = $encryptedContent;

View File

@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands\System;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\FilesystemException;
class VerifySecurityAlerts extends Command
@@ -48,7 +49,7 @@ class VerifySecurityAlerts extends Command
// check for security advisories.
$version = config('firefly.version');
$disk = \Storage::disk('resources');
$disk = Storage::disk('resources');
// Next line is ignored because it's a Laravel Facade.
if (!$disk->has('alerts.json')) { // @phpstan-ignore-line
app('log')->debug('No alerts.json file present.');

View File

@@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Preference;
use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
class RemovesDatabaseDecryption extends Command
@@ -152,7 +153,7 @@ class RemovesDatabaseDecryption extends Command
private function tryDecrypt($value)
{
try {
$value = \Crypt::decrypt($value);
$value = Crypt::decrypt($value);
} catch (DecryptException $e) {
if ('The MAC is invalid.' === $e->getMessage()) {
throw new FireflyException($e->getMessage(), 0, $e);