Bulk action permission check fixed.

This commit is contained in:
Cüneyt Şentürk 2020-02-13 15:49:43 +03:00
parent d9e9271858
commit 2000de7b7b
2 changed files with 82 additions and 68 deletions

View File

@ -29,6 +29,18 @@ BulkActions extends Controller
$bulk_actions = app('App\BulkActions\\' . ucfirst($group) . '\\' . ucfirst($type));
}
if (isset($bulk_actions->actions[$request->get('handle')]['permission']) && !user()->can($bulk_actions->actions[$request->get('handle')]['permission'])) {
flash(trans('errors.message.403'))->error();
return response()->json([
'success' => false,
'redirect' => true,
'error' => true,
'data' => [],
'message' => trans('errors.message.403')
]);
}
$result = $bulk_actions->{$request->get('handle')}($request);
if (!empty($result) && ($result instanceof \Symfony\Component\HttpFoundation\BinaryFileResponse)) {

View File

@ -31,12 +31,14 @@
@change="onChange">
<option value="*">{{ trans_choice('bulk_actions.bulk_actions', 2) }}</option>
@foreach($actions as $key => $action)
@if((!isset($action['permission'])) || (isset($action['permission']) && user()->can($action['permission'])))
<option
value="{{ $key }}"
@if(!empty($action['message']))
data-message="{{ trans_choice($action['message'], 2, ['type' => $text]) }}"
@endif
>{{ trans($action['name']) }}</option>
@endif
@endforeach
</select>