mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-19 13:03:05 -06:00
Can again destroy data.
This commit is contained in:
parent
f2e5e7d182
commit
d6dd6795fe
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/*
|
||||||
* DestroyController.php
|
* DestroyController.php
|
||||||
* Copyright (c) 2020 james@firefly-iii.org
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
*
|
*
|
||||||
@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Api\V1\Controllers\Data;
|
namespace FireflyIII\Api\V1\Controllers\Data;
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Controllers\Controller;
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Api\V1\Requests\DataDestroyRequest;
|
use FireflyIII\Api\V1\Requests\Data\DestroyRequest;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
@ -52,9 +52,12 @@ use Illuminate\Http\JsonResponse;
|
|||||||
class DestroyController extends Controller
|
class DestroyController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @param DestroyRequest $request
|
||||||
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function destroy(DataDestroyRequest $request): JsonResponse
|
public function destroy(DestroyRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$objects = $request->getObjects();
|
$objects = $request->getObjects();
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* UserController.php
|
* UserController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
*
|
*
|
||||||
@ -22,10 +22,11 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers\System;
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Requests\UserStoreRequest;
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
use FireflyIII\Api\V1\Requests\UserUpdateRequest;
|
use FireflyIII\Api\V1\Requests\System\UserStoreRequest;
|
||||||
|
use FireflyIII\Api\V1\Requests\System\UserUpdateRequest;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use FireflyIII\Transformers\UserTransformer;
|
use FireflyIII\Transformers\UserTransformer;
|
||||||
@ -72,10 +73,14 @@ class UserController extends Controller
|
|||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function delete(User $user): JsonResponse
|
public function destroy(User $user): JsonResponse
|
||||||
{
|
{
|
||||||
/** @var User $admin */
|
/** @var User $admin */
|
||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
|
if($admin->id === $user->id) {
|
||||||
|
return response()->json([], 500);
|
||||||
|
}
|
||||||
|
|
||||||
if ($admin->id !== $user->id && $this->repository->hasRole($admin, 'owner')) {
|
if ($admin->id !== $user->id && $this->repository->hasRole($admin, 'owner')) {
|
||||||
$this->repository->destroy($user);
|
$this->repository->destroy($user);
|
||||||
|
|
@ -21,16 +21,16 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests\Data;
|
||||||
|
|
||||||
use FireflyIII\Support\Request\ChecksLogin;
|
use FireflyIII\Support\Request\ChecksLogin;
|
||||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DataDestroyRequest
|
* Class DestroyRequest
|
||||||
*/
|
*/
|
||||||
class DataDestroyRequest extends FormRequest
|
class DestroyRequest extends FormRequest
|
||||||
{
|
{
|
||||||
use ConvertsDataTypes, ChecksLogin;
|
use ConvertsDataTypes, ChecksLogin;
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* UserStoreRequest.php
|
* UserStoreRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
*
|
*
|
||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests\System;
|
||||||
|
|
||||||
use FireflyIII\Rules\IsBoolean;
|
use FireflyIII\Rules\IsBoolean;
|
||||||
use FireflyIII\Support\Request\ChecksLogin;
|
use FireflyIII\Support\Request\ChecksLogin;
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* UserUpdateRequest.php
|
* UserUpdateRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
*
|
*
|
||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests\System;
|
||||||
|
|
||||||
use FireflyIII\Rules\IsBoolean;
|
use FireflyIII\Rules\IsBoolean;
|
||||||
use FireflyIII\Support\Request\ChecksLogin;
|
use FireflyIII\Support\Request\ChecksLogin;
|
@ -67,7 +67,7 @@ Route::group(
|
|||||||
/**
|
/**
|
||||||
* DATA ROUTES
|
* DATA ROUTES
|
||||||
*/
|
*/
|
||||||
// EXPORT
|
// Export data API routes
|
||||||
Route::group(
|
Route::group(
|
||||||
['namespace' => 'FireflyIII\Api\V1\Controllers\Data\Export', 'prefix' => 'data/export',
|
['namespace' => 'FireflyIII\Api\V1\Controllers\Data\Export', 'prefix' => 'data/export',
|
||||||
'as' => 'api.v1.data.export.',],
|
'as' => 'api.v1.data.export.',],
|
||||||
@ -83,6 +83,14 @@ Route::group(
|
|||||||
Route::get('transactions', ['uses' => 'ExportController@transactions', 'as' => 'transactions']);
|
Route::get('transactions', ['uses' => 'ExportController@transactions', 'as' => 'transactions']);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
// Destroy data API route
|
||||||
|
Route::group(
|
||||||
|
['namespace' => 'FireflyIII\Api\V1\Controllers\Data', 'prefix' => 'data/destroy',
|
||||||
|
'as' => 'api.v1.data.',],
|
||||||
|
static function () {
|
||||||
|
Route::delete('', ['uses' => 'DestroyController@destroy', 'as' => 'destroy']);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* INSIGHTS ROUTES
|
* INSIGHTS ROUTES
|
||||||
@ -488,7 +496,7 @@ Route::group(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Dynamic configuration API routes
|
// Configuration API routes
|
||||||
Route::group(
|
Route::group(
|
||||||
['namespace' => 'FireflyIII\Api\V1\Controllers\System', 'prefix' => 'configuration',
|
['namespace' => 'FireflyIII\Api\V1\Controllers\System', 'prefix' => 'configuration',
|
||||||
'as' => 'api.v1.configuration.',],
|
'as' => 'api.v1.configuration.',],
|
||||||
@ -499,18 +507,21 @@ Route::group(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// STATIC CONFIGURATION (NOT CHANGEABLE)
|
// Users API routes:
|
||||||
// TODO VERIFY API DOCS
|
Route::group(
|
||||||
//Route::group(
|
['middleware' => ['auth:api', 'bindings', IsAdmin::class], 'namespace' => 'FireflyIII\Api\V1\Controllers\System', 'prefix' => 'users',
|
||||||
// ['namespace' => 'FireflyIII\Api\V1\Controllers\System', 'prefix' => 'configuration/static',
|
'as' => 'api.v1.users.',],
|
||||||
// 'as' => 'api.v1.configuration.static.',],
|
static function () {
|
||||||
// static function () {
|
|
||||||
//
|
Route::get('', ['uses' => 'UserController@index', 'as' => 'index']);
|
||||||
// // Configuration API routes:
|
Route::post('', ['uses' => 'UserController@store', 'as' => 'store']);
|
||||||
// Route::get('', ['uses' => 'StaticConfigController@index', 'as' => 'index']);
|
Route::get('{user}', ['uses' => 'UserController@show', 'as' => 'show']);
|
||||||
// Route::get('{staticConfigKey}', ['uses' => 'StaticConfigController@show', 'as' => 'show']);
|
Route::put('{user}', ['uses' => 'UserController@update', 'as' => 'update']);
|
||||||
// }
|
Route::delete('{user}', ['uses' => 'UserController@destroy', 'as' => 'delete']);
|
||||||
//);
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -633,19 +644,7 @@ Route::group(
|
|||||||
//);
|
//);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//// destroy data route.
|
|
||||||
//// TODO VERIFY API DOCS
|
|
||||||
//Route::group(
|
|
||||||
// ['namespace' => 'FireflyIII\Api\V1\Controllers', 'prefix' => 'data',
|
|
||||||
// 'as' => 'api.v1.data.',],
|
|
||||||
// static function () {
|
|
||||||
//
|
|
||||||
// // Overview API routes:
|
|
||||||
// Route::delete('destroy', ['uses' => 'Data\DestroyController@destroy', 'as' => 'destroy']);
|
|
||||||
// }
|
|
||||||
//);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -673,17 +672,3 @@ Route::group(
|
|||||||
// }
|
// }
|
||||||
//);
|
//);
|
||||||
//
|
//
|
||||||
//// TODO VERIFY API DOCS
|
|
||||||
//Route::group(
|
|
||||||
// ['middleware' => ['auth:api', 'bindings', IsAdmin::class], 'namespace' => 'FireflyIII\Api\V1\Controllers', 'prefix' => 'users',
|
|
||||||
// 'as' => 'api.v1.users.',],
|
|
||||||
// static function () {
|
|
||||||
//
|
|
||||||
// // Users API routes:
|
|
||||||
// Route::get('', ['uses' => 'UserController@index', 'as' => 'index']);
|
|
||||||
// Route::post('', ['uses' => 'UserController@store', 'as' => 'store']);
|
|
||||||
// Route::get('{user}', ['uses' => 'UserController@show', 'as' => 'show']);
|
|
||||||
// Route::put('{user}', ['uses' => 'UserController@update', 'as' => 'update']);
|
|
||||||
// Route::delete('{user}', ['uses' => 'UserController@delete', 'as' => 'delete']);
|
|
||||||
// }
|
|
||||||
//);
|
|
||||||
|
Loading…
Reference in New Issue
Block a user