mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Auto commit for release 'develop' on 2024-08-05
This commit is contained in:
parent
0c9a41a929
commit
d98d757f8b
@ -68,13 +68,10 @@ class Handler extends ExceptionHandler
|
||||
JsonApiException::class,
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
public function register(): void
|
||||
{
|
||||
$this->renderable(
|
||||
ExceptionParser::make()->renderable()
|
||||
@ -101,7 +98,9 @@ class Handler extends ExceptionHandler
|
||||
if ($e instanceof JsonApiException) {
|
||||
// ignore it: controller will handle it.
|
||||
|
||||
app('log')->debug(sprintf('Return to parent to handle JsonApiException(%d)', $e->getCode()
|
||||
app('log')->debug(sprintf(
|
||||
'Return to parent to handle JsonApiException(%d)',
|
||||
$e->getCode()
|
||||
));
|
||||
|
||||
return parent::render($request, $e);
|
||||
|
@ -102,8 +102,6 @@ class AccountRepository extends AbstractRepository implements QueriesAll, Create
|
||||
/**
|
||||
* TODO piggy banks
|
||||
* TODO transactions
|
||||
*
|
||||
* @return CrudRelations
|
||||
*/
|
||||
protected function relations(): CrudRelations
|
||||
{
|
||||
|
@ -9,7 +9,6 @@ use FireflyIII\Rules\IsBoolean;
|
||||
use FireflyIII\Rules\IsValidPositiveAmount;
|
||||
use FireflyIII\Rules\UniqueAccountNumber;
|
||||
use FireflyIII\Rules\UniqueIban;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LaravelJsonApi\Laravel\Http\Requests\ResourceRequest;
|
||||
|
||||
@ -51,7 +50,6 @@ class AccountRequest extends ResourceRequest
|
||||
// 'interest' => 'min:0|max:100|numeric',
|
||||
// 'interest_period' => sprintf('nullable|in:%s', implode(',', config('firefly.interest_periods'))),
|
||||
// 'notes' => 'min:0|max:32768',
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,10 @@ class CrudAccount extends CrudResource
|
||||
return $enrichment->enrichSingle($account);
|
||||
}
|
||||
|
||||
public function create(array $validatedData): Account {
|
||||
var_dump($validatedData);exit;
|
||||
public function create(array $validatedData): Account
|
||||
{
|
||||
var_dump($validatedData);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,8 @@ class AccountPolicy
|
||||
return auth()->check() && $user->id === $account->user_id;
|
||||
}
|
||||
|
||||
public function create(): bool {
|
||||
public function create(): bool
|
||||
{
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Rules\Account;
|
||||
|
||||
use Closure;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\User;
|
||||
@ -35,13 +34,11 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
||||
*/
|
||||
class IsUniqueAccount implements ValidationRule, DataAwareRule
|
||||
{
|
||||
protected Closure $fail;
|
||||
protected \Closure $fail;
|
||||
protected array $data = [];
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
#[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
#[\Override]
|
||||
public function validate(string $attribute, mixed $value, \Closure $fail): void
|
||||
{
|
||||
return;
|
||||
$this->fail = $fail;
|
||||
@ -49,6 +46,7 @@ class IsUniqueAccount implements ValidationRule, DataAwareRule
|
||||
if (!auth()->check()) {
|
||||
app('log')->debug('validateUniqueAccountForUser::anon');
|
||||
$fail('validation.nog_logged_in')->translate();
|
||||
|
||||
return;
|
||||
}
|
||||
if (array_key_exists('type', $this->data)) {
|
||||
@ -77,17 +75,10 @@ class IsUniqueAccount implements ValidationRule, DataAwareRule
|
||||
app('log')->debug('validateUniqueAccountForUser::accountName');
|
||||
|
||||
$this->validateByAccountName($value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO duplicate from old validation class.
|
||||
*
|
||||
* @param string $value
|
||||
* @param array $parameters
|
||||
* @param string $type
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function validateByAccountTypeString(string $value, array $parameters, string $type): bool
|
||||
{
|
||||
@ -105,15 +96,14 @@ class IsUniqueAccount implements ValidationRule, DataAwareRule
|
||||
/** @var null|Account $result */
|
||||
$result = auth()->user()->accounts()->whereIn('account_type_id', $accountTypeIds)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first();
|
||||
->first()
|
||||
;
|
||||
|
||||
return null === $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO duplicate from old validation class.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function validateAccountAnonymously(): void
|
||||
{
|
||||
@ -146,7 +136,8 @@ class IsUniqueAccount implements ValidationRule, DataAwareRule
|
||||
/** @var null|Account $result */
|
||||
$result = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first();
|
||||
->first()
|
||||
;
|
||||
|
||||
return null === $result;
|
||||
}
|
||||
@ -166,7 +157,8 @@ class IsUniqueAccount implements ValidationRule, DataAwareRule
|
||||
|
||||
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first();
|
||||
->first()
|
||||
;
|
||||
|
||||
return null === $entry;
|
||||
}
|
||||
@ -186,7 +178,8 @@ class IsUniqueAccount implements ValidationRule, DataAwareRule
|
||||
|
||||
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first();
|
||||
->first()
|
||||
;
|
||||
|
||||
return null === $entry;
|
||||
}
|
||||
@ -194,20 +187,14 @@ class IsUniqueAccount implements ValidationRule, DataAwareRule
|
||||
/**
|
||||
* TODO is duplicate
|
||||
* TODO does not take group into account. Must be made group aware.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function validateByAccountName(string $value): bool
|
||||
{
|
||||
return 0 === auth()->user()->accounts()->where('name', $value)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
#[\Override] public function setData(array $data): void
|
||||
#[\Override]
|
||||
public function setData(array $data): void
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
12
package-lock.json
generated
12
package-lock.json
generated
@ -4011,9 +4011,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/caniuse-lite": {
|
||||
"version": "1.0.30001647",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001647.tgz",
|
||||
"integrity": "sha512-n83xdNiyeNcHpzWY+1aFbqCK7LuLfBricc4+alSQL2Xb6OR3XpnQAmlDG+pQcdTfiHRuLcQ96VOfrPSGiNJYSg==",
|
||||
"version": "1.0.30001649",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001649.tgz",
|
||||
"integrity": "sha512-fJegqZZ0ZX8HOWr6rcafGr72+xcgJKI9oWfDW5DrD7ExUtgZC7a7R7ZYmZqplh7XDocFdGeIFn7roAxhOeYrPQ==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
@ -6966,9 +6966,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/launch-editor": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.8.0.tgz",
|
||||
"integrity": "sha512-vJranOAJrI/llyWGRQqiDM+adrw+k83fvmmx3+nV47g3+36xM15jE+zyZ6Ffel02+xSvuM0b2GDRosXZkbb6wA==",
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.8.1.tgz",
|
||||
"integrity": "sha512-elBx2l/tp9z99X5H/qev8uyDywVh0VXAwEbjk8kJhnc5grOFkGh7aW6q55me9xnYbss261XtnUrysZ+XvGbhQA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"picocolors": "^1.0.0",
|
||||
|
@ -246,13 +246,15 @@ JsonApiRoute::server('v2')->prefix('v2')
|
||||
$server->resource('accounts', AccountController::class)
|
||||
->relationships(function (Relationships $relations): void {
|
||||
$relations->hasOne('user')->readOnly();
|
||||
});
|
||||
})
|
||||
;
|
||||
|
||||
// USERS
|
||||
$server->resource('users', JsonApiController::class)->readOnly()->relationships(function (Relationships $relations): void {
|
||||
$relations->hasMany('accounts')->readOnly();
|
||||
});
|
||||
});
|
||||
})
|
||||
;
|
||||
|
||||
/*
|
||||
* ____ ____ __ .______ ______ __ __ .___________. _______ _______.
|
||||
|
Loading…
Reference in New Issue
Block a user