Skip to content

Commit

Permalink
Readded the permission checks
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterZydra committed Feb 21, 2024
1 parent 98f5a00 commit fc7307f
Show file tree
Hide file tree
Showing 32 changed files with 281 additions and 163 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Types of changes: `Added`, `Changed`, `Deprecate`, `Removed`, `Fixed`, `Secruity

## [Unreleased]

## v2.0.0 - 21.02.2024 - Same frontend with new backend

### Added
- Added bioman CLI that can be extended with commands
- Added `registerFn` to simplify registering global available functions
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/ActiveSuppliersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use Framework\Authentication\Auth;
use Framework\Facades\Http;
use Framework\PDF\PDF;
use Framework\Routing\BaseController;
Expand All @@ -11,6 +12,8 @@ class ActiveSuppliersController extends BaseController implements ControllerInte
{
public function execute(): void
{
Auth::checkRole('Maintainer');

if (Http::requestMethod() !== 'GET') {
Http::redirect('/');
return;
Expand Down
13 changes: 13 additions & 0 deletions app/Http/Controllers/DeliveryNoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Models\DeliveryNote;
use Framework\Authentication\Auth;
use Framework\Database\Query\SortOrder;
use Framework\Facades\Http;
use Framework\Routing\BaseController;
Expand All @@ -16,6 +17,8 @@ class DeliveryNoteController extends BaseController implements ModelControllerIn
*/
public function index(): void
{
Auth::checkRole('Maintainer');

view(
'entities.deliveryNote.index',
['deliveryNotes' => DeliveryNote::all(
Expand All @@ -32,6 +35,8 @@ public function index(): void
*/
public function create(): void
{
Auth::checkRole('Maintainer');

view('entities.deliveryNote.create');
}

Expand All @@ -41,6 +46,8 @@ public function create(): void
*/
public function store(): void
{
Auth::checkRole('Maintainer');

(new DeliveryNote())
->setFromHttpParams(['year', 'productId', 'supplierId', 'recipientId'])
->setNr(DeliveryNote::nextDeliveryNoteNr(Http::param('year')))
Expand All @@ -59,6 +66,8 @@ public function store(): void
*/
public function edit(): void
{
Auth::checkRole('Maintainer');

view('entities.deliveryNote.edit', ['deliveryNote' => DeliveryNote::findById(Http::param('id'))]);
}

Expand All @@ -68,6 +77,8 @@ public function edit(): void
*/
public function update(): void
{
Auth::checkRole('Maintainer');

DeliveryNote::findById(Http::param('id'))
->setFromHttpParams(['deliveryDate', 'amount', 'productId', 'supplierId', 'recipientId', 'isInvoiceReady'])
->save();
Expand All @@ -81,6 +92,8 @@ public function update(): void
*/
public function destroy(): void
{
Auth::checkRole('Maintainer');

DeliveryNote::delete(Http::param('id'));

Http::redirect('deliveryNote');
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/EditImprintSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Models\Setting;
use Framework\Authentication\Auth;
use Framework\Facades\Http;
use Framework\Routing\BaseController;
use Framework\Routing\ControllerInterface;
Expand All @@ -11,6 +12,8 @@ class EditImprintSettingsController extends BaseController implements Controller
{
public function execute(): void
{
Auth::checkRole('Administrator');

if (Http::requestMethod() === 'GET') {
view('settings.editImprint');
return;
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/EditInvoiceSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Models\Setting;
use Framework\Authentication\Auth;
use Framework\Facades\Http;
use Framework\Routing\BaseController;
use Framework\Routing\ControllerInterface;
Expand All @@ -11,6 +12,8 @@ class EditInvoiceSettingsController extends BaseController implements Controller
{
public function execute(): void
{
Auth::checkRole('Administrator');

if (Http::requestMethod() === 'GET') {
view('settings.editInvoice');
return;
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/EditVolumeDistributionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\DeliveryNote;
use App\Models\VolumeDistribution;
use Framework\Authentication\Auth;
use Framework\Facades\Http;
use Framework\Message\Message;
use Framework\Message\Type;
Expand All @@ -14,6 +15,8 @@ class EditVolumeDistributionController extends BaseController implements Control
{
public function execute(): void
{
Auth::checkRole('Maintainer');

if (Http::requestMethod() === 'GET') {
view('entities.volumeDistribution.edit', [
'deliveryNote' => DeliveryNote::findById(Http::param('id')),
Expand Down
15 changes: 15 additions & 0 deletions app/Http/Controllers/InvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\DeliveryNote;
use App\Models\Invoice;
use Framework\Authentication\Auth;
use Framework\Database\Query\SortOrder;
use Framework\Facades\Http;
use Framework\PDF\PDF;
Expand All @@ -18,6 +19,8 @@ class InvoiceController extends BaseController implements ModelControllerInterfa
*/
public function index(): void
{
Auth::checkRole('Maintainer');

view(
'entities.invoice.index',
['invoices' => Invoice::all(
Expand All @@ -34,6 +37,8 @@ public function index(): void
*/
public function show(): void
{
Auth::checkRole('Maintainer');

$invoice = Invoice::findById(Http::param('id'));
(new PDF())
->createPDF(setting('invoiceAuthor'), $invoice->PdfInvoiceName(), $invoice->PdfInvoiceName(), render('pdf.invoice', ['invoice' => $invoice]))
Expand All @@ -46,6 +51,8 @@ public function show(): void
*/
public function create(): void
{
Auth::checkRole('Maintainer');

view('entities.invoice.create');
}

Expand All @@ -55,6 +62,8 @@ public function create(): void
*/
public function store(): void
{
Auth::checkRole('Maintainer');

$year = Http::param('year');
$nr = Invoice::nextInvoiceNr(Http::param('year'));

Expand All @@ -77,6 +86,8 @@ public function store(): void
*/
public function edit(): void
{
Auth::checkRole('Maintainer');

view('entities.invoice.edit', ['invoice' => Invoice::findById(Http::param('id'))]);
}

Expand All @@ -86,6 +97,8 @@ public function edit(): void
*/
public function update(): void
{
Auth::checkRole('Maintainer');

$invoice = Invoice::findById(Http::param('id'))
->setFromHttpParams(['invoiceDate', 'recipientId', 'isPaid'])
->save();
Expand All @@ -106,6 +119,8 @@ public function update(): void
*/
public function destroy(): void
{
Auth::checkRole('Maintainer');

Invoice::delete(Http::param('id'));

Http::redirect('invoice');
Expand Down
13 changes: 13 additions & 0 deletions app/Http/Controllers/PlotController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Models\Plot;
use Framework\Authentication\Auth;
use Framework\Facades\Http;
use Framework\Routing\BaseController;
use Framework\Routing\ModelControllerInterface;
Expand All @@ -15,6 +16,8 @@ class PlotController extends BaseController implements ModelControllerInterface
*/
public function index(): void
{
Auth::checkRole('Maintainer');

view('entities.plot.index', ['plots' => Plot::all()]);
}

Expand All @@ -24,6 +27,8 @@ public function index(): void
*/
public function create(): void
{
Auth::checkRole('Maintainer');

view('entities.plot.create');
}

Expand All @@ -33,6 +38,8 @@ public function create(): void
*/
public function store(): void
{
Auth::checkRole('Maintainer');

(new Plot())
->setFromHttpParams(['nr', 'name', 'subdistrict', 'supplierId'])
->setIsLocked(false)
Expand All @@ -47,6 +54,8 @@ public function store(): void
*/
public function edit(): void
{
Auth::checkRole('Maintainer');

view('entities.plot.edit', ['plot' => Plot::findById(Http::param('id'))]);
}

Expand All @@ -56,6 +65,8 @@ public function edit(): void
*/
public function update(): void
{
Auth::checkRole('Maintainer');

Plot::findById(Http::param('id'))
->setFromHttpParams(['nr', 'name', 'subdistrict', 'supplierId', 'isLocked'])
->save();
Expand All @@ -69,6 +80,8 @@ public function update(): void
*/
public function destroy(): void
{
Auth::checkRole('Maintainer');

Plot::delete(Http::param('id'));

Http::redirect('plot');
Expand Down
Loading

0 comments on commit fc7307f

Please sign in to comment.