mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Fix various code.
This commit is contained in:
@@ -162,7 +162,7 @@ class RemoteUserGuard implements Guard
|
|||||||
app('log')->error(sprintf('Did not set user at %s', __METHOD__));
|
app('log')->error(sprintf('Did not set user at %s', __METHOD__));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate(array $credentials = []): void
|
public function validate(array $credentials = []): bool
|
||||||
{
|
{
|
||||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||||
|
|
||||||
|
@@ -36,13 +36,21 @@ use Illuminate\Contracts\Auth\UserProvider;
|
|||||||
*/
|
*/
|
||||||
class RemoteUserProvider implements UserProvider
|
class RemoteUserProvider implements UserProvider
|
||||||
{
|
{
|
||||||
public function retrieveByCredentials(array $credentials): void
|
/**
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function retrieveByCredentials(array $credentials): null|Authenticatable
|
||||||
{
|
{
|
||||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||||
|
|
||||||
throw new FireflyException(sprintf('Did not implement %s', __METHOD__));
|
throw new FireflyException(sprintf('Did not implement %s', __METHOD__));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $identifier
|
||||||
|
*
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
public function retrieveById($identifier): User
|
public function retrieveById($identifier): User
|
||||||
{
|
{
|
||||||
app('log')->debug(sprintf('Now at %s(%s)', __METHOD__, $identifier));
|
app('log')->debug(sprintf('Now at %s(%s)', __METHOD__, $identifier));
|
||||||
@@ -70,7 +78,13 @@ class RemoteUserProvider implements UserProvider
|
|||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function retrieveByToken($identifier, $token): void
|
/**
|
||||||
|
* @param mixed $identifier
|
||||||
|
* @param mixed $token
|
||||||
|
*
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function retrieveByToken($identifier, $token): null|Authenticatable
|
||||||
{
|
{
|
||||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||||
|
|
||||||
@@ -84,7 +98,10 @@ class RemoteUserProvider implements UserProvider
|
|||||||
throw new FireflyException(sprintf('B) Did not implement %s', __METHOD__));
|
throw new FireflyException(sprintf('B) Did not implement %s', __METHOD__));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateCredentials(Authenticatable $user, array $credentials): void
|
/**
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function validateCredentials(Authenticatable $user, array $credentials): bool
|
||||||
{
|
{
|
||||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||||
|
|
||||||
|
@@ -249,14 +249,9 @@ class ParseDateString
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this matches regex for xxxx-xx-DD:
|
* Returns true if this matches regex for xxxx-xx-DD:
|
||||||
*
|
|
||||||
* @param string $date
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
protected function isDayRange(string $date): bool
|
protected function isDayRange(string $date): bool
|
||||||
{
|
{
|
||||||
|
|
||||||
$pattern = '/^xxxx-xx-(0[1-9]|[12]\d|3[01])$/';
|
$pattern = '/^xxxx-xx-(0[1-9]|[12]\d|3[01])$/';
|
||||||
$result = preg_match($pattern, $date);
|
$result = preg_match($pattern, $date);
|
||||||
if (false !== $result && 0 !== $result) {
|
if (false !== $result && 0 !== $result) {
|
||||||
|
@@ -697,10 +697,6 @@ class Steam
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user's locale.
|
* Get user's locale.
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
* @throws ContainerExceptionInterface
|
|
||||||
* @throws NotFoundExceptionInterface
|
|
||||||
*/
|
*/
|
||||||
public function getLocale(): string // get preference
|
public function getLocale(): string // get preference
|
||||||
{
|
{
|
||||||
|
@@ -212,7 +212,7 @@ class FireflyValidator extends Validator
|
|||||||
// take
|
// take
|
||||||
$first = substr($value, 0, 4);
|
$first = substr($value, 0, 4);
|
||||||
$last = substr($value, 4);
|
$last = substr($value, 4);
|
||||||
$iban = $last . $first;
|
$iban = $last.$first;
|
||||||
$iban = trim(str_replace($search, $replace, $iban));
|
$iban = trim(str_replace($search, $replace, $iban));
|
||||||
if ('' === $iban) {
|
if ('' === $iban) {
|
||||||
return false;
|
return false;
|
||||||
@@ -507,10 +507,11 @@ class FireflyValidator extends Validator
|
|||||||
}
|
}
|
||||||
|
|
||||||
$query = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
|
$query = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
|
||||||
->whereNull('accounts.deleted_at')
|
->whereNull('accounts.deleted_at')
|
||||||
->where('accounts.user_id', auth()->user()->id)
|
->where('accounts.user_id', auth()->user()->id)
|
||||||
->where('account_meta.name', 'account_number')
|
->where('account_meta.name', 'account_number')
|
||||||
->where('account_meta.data', json_encode($value));
|
->where('account_meta.data', json_encode($value))
|
||||||
|
;
|
||||||
|
|
||||||
if ($accountId > 0) {
|
if ($accountId > 0) {
|
||||||
// exclude current account from check.
|
// exclude current account from check.
|
||||||
@@ -552,7 +553,7 @@ class FireflyValidator extends Validator
|
|||||||
/**
|
/**
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
public function validateUniqueCurrencyCode(null | string $attribute, null | string $value): bool
|
public function validateUniqueCurrencyCode(null|string $attribute, null|string $value): bool
|
||||||
{
|
{
|
||||||
return $this->validateUniqueCurrency('code', (string) $attribute, (string) $value);
|
return $this->validateUniqueCurrency('code', (string) $attribute, (string) $value);
|
||||||
}
|
}
|
||||||
@@ -565,12 +566,12 @@ class FireflyValidator extends Validator
|
|||||||
return 0 === \DB::table('transaction_currencies')->where($field, $value)->whereNull('deleted_at')->count();
|
return 0 === \DB::table('transaction_currencies')->where($field, $value)->whereNull('deleted_at')->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateUniqueCurrencyName(null | string $attribute, null | string $value): bool
|
public function validateUniqueCurrencyName(null|string $attribute, null|string $value): bool
|
||||||
{
|
{
|
||||||
return $this->validateUniqueCurrency('name', (string) $attribute, (string) $value);
|
return $this->validateUniqueCurrency('name', (string) $attribute, (string) $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateUniqueCurrencySymbol(null | string $attribute, null | string $value): bool
|
public function validateUniqueCurrencySymbol(null|string $attribute, null|string $value): bool
|
||||||
{
|
{
|
||||||
return $this->validateUniqueCurrency('symbol', (string) $attribute, (string) $value);
|
return $this->validateUniqueCurrency('symbol', (string) $attribute, (string) $value);
|
||||||
}
|
}
|
||||||
@@ -613,11 +614,12 @@ class FireflyValidator extends Validator
|
|||||||
$userId = auth()->user()->id;
|
$userId = auth()->user()->id;
|
||||||
|
|
||||||
return 0 === Webhook::whereUserId($userId)
|
return 0 === Webhook::whereUserId($userId)
|
||||||
->where('trigger', $trigger)
|
->where('trigger', $trigger)
|
||||||
->where('response', $response)
|
->where('response', $response)
|
||||||
->where('delivery', $delivery)
|
->where('delivery', $delivery)
|
||||||
->where('id', '!=', $existingId)
|
->where('id', '!=', $existingId)
|
||||||
->where('url', $url)->count();
|
->where('url', $url)->count()
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -651,9 +653,10 @@ class FireflyValidator extends Validator
|
|||||||
}
|
}
|
||||||
// get entries from table
|
// get entries from table
|
||||||
$result = \DB::table($table)->where('user_id', auth()->user()->id)->whereNull('deleted_at')
|
$result = \DB::table($table)->where('user_id', auth()->user()->id)->whereNull('deleted_at')
|
||||||
->where('id', '!=', $exclude)
|
->where('id', '!=', $exclude)
|
||||||
->where($field, $value)
|
->where($field, $value)
|
||||||
->first([$field]);
|
->first([$field])
|
||||||
|
;
|
||||||
if (null === $result) {
|
if (null === $result) {
|
||||||
return true; // not found, so true.
|
return true; // not found, so true.
|
||||||
}
|
}
|
||||||
@@ -673,9 +676,10 @@ class FireflyValidator extends Validator
|
|||||||
{
|
{
|
||||||
$exclude = $parameters[0] ?? null;
|
$exclude = $parameters[0] ?? null;
|
||||||
$query = \DB::table('object_groups')
|
$query = \DB::table('object_groups')
|
||||||
->whereNull('object_groups.deleted_at')
|
->whereNull('object_groups.deleted_at')
|
||||||
->where('object_groups.user_id', auth()->user()->id)
|
->where('object_groups.user_id', auth()->user()->id)
|
||||||
->where('object_groups.title', $value);
|
->where('object_groups.title', $value)
|
||||||
|
;
|
||||||
if (null !== $exclude) {
|
if (null !== $exclude) {
|
||||||
$query->where('object_groups.id', '!=', (int) $exclude);
|
$query->where('object_groups.id', '!=', (int) $exclude);
|
||||||
}
|
}
|
||||||
@@ -694,7 +698,8 @@ class FireflyValidator extends Validator
|
|||||||
{
|
{
|
||||||
$exclude = $parameters[0] ?? null;
|
$exclude = $parameters[0] ?? null;
|
||||||
$query = \DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at')
|
$query = \DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at')
|
||||||
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', auth()->user()->id);
|
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', auth()->user()->id)
|
||||||
|
;
|
||||||
if (null !== $exclude) {
|
if (null !== $exclude) {
|
||||||
$query->where('piggy_banks.id', '!=', (int) $exclude);
|
$query->where('piggy_banks.id', '!=', (int) $exclude);
|
||||||
}
|
}
|
||||||
@@ -724,10 +729,11 @@ class FireflyValidator extends Validator
|
|||||||
$userId = auth()->user()->id;
|
$userId = auth()->user()->id;
|
||||||
|
|
||||||
return 0 === Webhook::whereUserId($userId)
|
return 0 === Webhook::whereUserId($userId)
|
||||||
->where('trigger', $trigger)
|
->where('trigger', $trigger)
|
||||||
->where('response', $response)
|
->where('response', $response)
|
||||||
->where('delivery', $delivery)
|
->where('delivery', $delivery)
|
||||||
->where('url', $url)->count();
|
->where('url', $url)->count()
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -753,7 +759,7 @@ class FireflyValidator extends Validator
|
|||||||
private function validateByAccountTypeString(string $value, array $parameters, string $type): bool
|
private function validateByAccountTypeString(string $value, array $parameters, string $type): bool
|
||||||
{
|
{
|
||||||
/** @var null|array $search */
|
/** @var null|array $search */
|
||||||
$search = \Config::get('firefly.accountTypeByIdentifier.' . $type);
|
$search = \Config::get('firefly.accountTypeByIdentifier.'.$type);
|
||||||
|
|
||||||
if (null === $search) {
|
if (null === $search) {
|
||||||
return false;
|
return false;
|
||||||
@@ -765,8 +771,9 @@ class FireflyValidator extends Validator
|
|||||||
|
|
||||||
/** @var null|Account $result */
|
/** @var null|Account $result */
|
||||||
$result = auth()->user()->accounts()->whereIn('account_type_id', $accountTypeIds)->where('id', '!=', $ignore)
|
$result = auth()->user()->accounts()->whereIn('account_type_id', $accountTypeIds)->where('id', '!=', $ignore)
|
||||||
->where('name', $value)
|
->where('name', $value)
|
||||||
->first();
|
->first()
|
||||||
|
;
|
||||||
|
|
||||||
return null === $result;
|
return null === $result;
|
||||||
}
|
}
|
||||||
@@ -782,8 +789,9 @@ class FireflyValidator extends Validator
|
|||||||
|
|
||||||
/** @var null|Account $result */
|
/** @var null|Account $result */
|
||||||
$result = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
$result = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||||
->where('name', $value)
|
->where('name', $value)
|
||||||
->first();
|
->first()
|
||||||
|
;
|
||||||
|
|
||||||
return null === $result;
|
return null === $result;
|
||||||
}
|
}
|
||||||
@@ -800,8 +808,9 @@ class FireflyValidator extends Validator
|
|||||||
$ignore = $existingAccount->id;
|
$ignore = $existingAccount->id;
|
||||||
|
|
||||||
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||||
->where('name', $value)
|
->where('name', $value)
|
||||||
->first();
|
->first()
|
||||||
|
;
|
||||||
|
|
||||||
return null === $entry;
|
return null === $entry;
|
||||||
}
|
}
|
||||||
@@ -818,8 +827,9 @@ class FireflyValidator extends Validator
|
|||||||
$ignore = $existingAccount->id;
|
$ignore = $existingAccount->id;
|
||||||
|
|
||||||
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||||
->where('name', $value)
|
->where('name', $value)
|
||||||
->first();
|
->first()
|
||||||
|
;
|
||||||
|
|
||||||
return null === $entry;
|
return null === $entry;
|
||||||
}
|
}
|
||||||
|
@@ -291,6 +291,7 @@ Breadcrumbs::for(
|
|||||||
Breadcrumbs::for(
|
Breadcrumbs::for(
|
||||||
'attachments.edit',
|
'attachments.edit',
|
||||||
static function (Generator $breadcrumbs, Attachment $attachment): void {
|
static function (Generator $breadcrumbs, Attachment $attachment): void {
|
||||||
|
/** @var Account|Bill|TransactionJournal $object */
|
||||||
$object = $attachment->attachable;
|
$object = $attachment->attachable;
|
||||||
if ($object instanceof TransactionJournal) {
|
if ($object instanceof TransactionJournal) {
|
||||||
$group = $object->transactionGroup;
|
$group = $object->transactionGroup;
|
||||||
@@ -311,6 +312,7 @@ Breadcrumbs::for(
|
|||||||
Breadcrumbs::for(
|
Breadcrumbs::for(
|
||||||
'attachments.delete',
|
'attachments.delete',
|
||||||
static function (Generator $breadcrumbs, Attachment $attachment): void {
|
static function (Generator $breadcrumbs, Attachment $attachment): void {
|
||||||
|
/** @var Account|Bill|TransactionJournal $object */
|
||||||
$object = $attachment->attachable;
|
$object = $attachment->attachable;
|
||||||
if ($object instanceof TransactionJournal) {
|
if ($object instanceof TransactionJournal) {
|
||||||
$breadcrumbs->parent('transactions.show', $object->transactionGroup);
|
$breadcrumbs->parent('transactions.show', $object->transactionGroup);
|
||||||
|
Reference in New Issue
Block a user