Bulk action permission check fixed.
This commit is contained in:
parent
d9e9271858
commit
2000de7b7b
@ -29,6 +29,18 @@ BulkActions extends Controller
|
|||||||
$bulk_actions = app('App\BulkActions\\' . ucfirst($group) . '\\' . ucfirst($type));
|
$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);
|
$result = $bulk_actions->{$request->get('handle')}($request);
|
||||||
|
|
||||||
if (!empty($result) && ($result instanceof \Symfony\Component\HttpFoundation\BinaryFileResponse)) {
|
if (!empty($result) && ($result instanceof \Symfony\Component\HttpFoundation\BinaryFileResponse)) {
|
||||||
|
@ -31,12 +31,14 @@
|
|||||||
@change="onChange">
|
@change="onChange">
|
||||||
<option value="*">{{ trans_choice('bulk_actions.bulk_actions', 2) }}</option>
|
<option value="*">{{ trans_choice('bulk_actions.bulk_actions', 2) }}</option>
|
||||||
@foreach($actions as $key => $action)
|
@foreach($actions as $key => $action)
|
||||||
|
@if((!isset($action['permission'])) || (isset($action['permission']) && user()->can($action['permission'])))
|
||||||
<option
|
<option
|
||||||
value="{{ $key }}"
|
value="{{ $key }}"
|
||||||
@if(!empty($action['message']))
|
@if(!empty($action['message']))
|
||||||
data-message="{{ trans_choice($action['message'], 2, ['type' => $text]) }}"
|
data-message="{{ trans_choice($action['message'], 2, ['type' => $text]) }}"
|
||||||
@endif
|
@endif
|
||||||
>{{ trans($action['name']) }}</option>
|
>{{ trans($action['name']) }}</option>
|
||||||
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user