From 64f4c7d69d17bf59384a2f4d4f32342f357d9493 Mon Sep 17 00:00:00 2001 From: HUET Benjamin Date: Wed, 8 Mar 2017 21:48:36 +0100 Subject: [PATCH] fixed routes permissions --- src/Http/Controllers/OperationController.php | 24 +++++++++---------- src/Http/routes.php | 5 +++- .../modals/confirm_activate.blade.php | 2 +- .../includes/modals/confirm_cancel.blade.php | 2 +- .../includes/modals/confirm_close.blade.php | 2 +- .../includes/modals/confirm_delete.blade.php | 2 +- .../modals/create_operation.blade.php | 2 +- .../includes/modals/details.blade.php | 10 ++++---- .../includes/modals/subscribe.blade.php | 2 +- .../modals/update_operation.blade.php | 2 +- 10 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/Http/Controllers/OperationController.php b/src/Http/Controllers/OperationController.php index df9396f..dcc2745 100644 --- a/src/Http/Controllers/OperationController.php +++ b/src/Http/Controllers/OperationController.php @@ -145,7 +145,7 @@ public function update(Request $request) return $operation; } - return redirect()->route('auth.unauthorized'); + return redirect()->back('error', 'An error occurred while processing the request.'); } public function delete(Request $request) @@ -154,11 +154,11 @@ public function delete(Request $request) if ($operation != null) { if (auth()->user()->has('calendar.deleteAll') || $operation->user->id == auth()->user()->id) { Operation::destroy($operation->id); - return redirect()->back(); + return redirect()->route('operation.index'); } } - return redirect()->route('auth.unauthorized'); + return redirect()->back('error', 'An error occurred while processing the request.'); } public function close(Request $request) @@ -170,11 +170,11 @@ public function close(Request $request) $operation->end_at = Carbon::now('UTC'); $operation->save(); - return redirect()->back(); + return redirect()->route('operation.index'); } } - return redirect()->route('auth.unauthorized'); + return redirect()->back('error', 'An error occurred while processing the request.'); } public function cancel(Request $request) @@ -188,11 +188,11 @@ public function cancel(Request $request) $operation->notify = $request->get('notify'); $operation->save(); - return redirect()->back(); + return redirect()->route('operation.index'); } } - return redirect()->route('auth.unauthorized'); + return redirect()->back('error', 'An error occurred while processing the request.'); } public function activate(Request $request) @@ -206,11 +206,11 @@ public function activate(Request $request) $operation->notify = $request->get('notify'); $operation->save(); - return redirect()->back(); + return redirect()->route('operation.index'); } } - return redirect()->route('auth.unauthorized'); + return redirect()->back('error', 'An error occurred while processing the request.'); } public function subscribe(Request $request) @@ -230,11 +230,11 @@ public function subscribe(Request $request) 'comment' => $request->comment ] ); - return redirect()->back(); + return redirect()->route('operation.index'); } } - return redirect()->route('auth.unauthorized'); + return redirect()->back('error', 'An error occurred while processing the request.'); } public function find($operation_id) { @@ -243,7 +243,7 @@ public function find($operation_id) { return response()->json($operation); } - return redirect()->route('auth.unauthorized'); + return redirect()->back('error', 'An error occurred while processing the request.'); } } \ No newline at end of file diff --git a/src/Http/routes.php b/src/Http/routes.php index d556485..b6dc398 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -7,7 +7,10 @@ ], function () { Route::resource('operation', 'OperationController', [ - 'only' => ['index', 'store'] + 'only' => ['index', 'store'], + 'names' => [ + 'index' => 'operation.index' + ] ]); Route::post('operation/subscribe', [ diff --git a/src/resources/views/operation/includes/modals/confirm_activate.blade.php b/src/resources/views/operation/includes/modals/confirm_activate.blade.php index fee484d..8628840 100644 --- a/src/resources/views/operation/includes/modals/confirm_activate.blade.php +++ b/src/resources/views/operation/includes/modals/confirm_activate.blade.php @@ -1,4 +1,4 @@ -