mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-24 16:10:37 -06:00
Update various routes
This commit is contained in:
parent
eb0281e47f
commit
1f3badb731
@ -77,7 +77,7 @@ class ShowController extends Controller
|
||||
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||
|
||||
// get list of budgets. Count it and split it.
|
||||
$collection = $this->repository->getAll();
|
||||
$collection = $this->repository->get();
|
||||
$count = $collection->count();
|
||||
$piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
|
||||
|
@ -28,6 +28,7 @@ use FireflyIII\Rules\IsBoolean;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
/**
|
||||
* Class UserUpdateRequest
|
||||
@ -43,7 +44,7 @@ class UserUpdateRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->check() && auth()->user()->hasRole('owner');
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,4 +84,25 @@ class UserUpdateRequest extends FormRequest
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the validator instance.
|
||||
*
|
||||
* @param Validator $validator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$current = $this->route()->parameter('user');
|
||||
$validator->after(
|
||||
static function (Validator $validator) use($current) {
|
||||
$isAdmin = auth()->user()->hasRole('owner');
|
||||
// not admin, and not own user?
|
||||
if (auth()->check() && false === $isAdmin && $current?->id !== auth()->user()->id) {
|
||||
$validator->errors()->add('email', (string) trans('validation.invalid_selection'));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ Route::group(
|
||||
);
|
||||
// Users API routes:
|
||||
Route::group(
|
||||
['middleware' => ['auth:api', 'bindings', IsAdmin::class], 'namespace' => 'FireflyIII\Api\V1\Controllers\System', 'prefix' => 'users',
|
||||
['middleware' => ['auth:api,sanctum', 'bindings'], 'namespace' => 'FireflyIII\Api\V1\Controllers\System', 'prefix' => 'users',
|
||||
'as' => 'api.v1.users.',],
|
||||
static function () {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user