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