Skip to content

Commit 518d549

Browse files
committed
Restrict access to update and delete actions in MediaAdmin view
The update has modified the MediaAdmin/edit.html.twig file to restrict the display of update and delete buttons. These actions are only visible now if the admin.id(object) exists, providing an additional layer of access control. The change improves the management and the security within the media admin view.
1 parent 9fcb351 commit 518d549

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/Resources/views/MediaAdmin/edit.html.twig

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,17 @@ file that was distributed with this source code.
265265
<input class="btn btn-sm btninfo persist-preview" name="btn_preview" type="submit"
266266
value="{{ 'btn_preview'|trans({'%admin_label%': admin_label}, 'NetworkingInitCmsBundle') }}"/>
267267
{% endif %}
268-
<input type="submit" class="btn btn-sm btn-primary" name="btn_update_and_edit"
269-
value="{{ 'btn_update_and_edit_again'|trans({'%admin_label%': admin_label}, 'NetworkingInitCmsBundle') }}"/>
270-
<input type="submit" class="btn btn-sm btn-light" name="btn_update_and_list"
271-
value="{{ 'btn_update_and_return_to_list'|trans({'%admin_label%': admin_label}, 'NetworkingInitCmsBundle') }}"/>
272-
273-
{% if admin.hasroute('delete') and admin.isGranted('DELETE', object) and (object.isDeletable() is not defined or object.isDeletable == 1 ) %}
274-
{{ 'delete_or'|trans({}, 'SonataAdminBundle') }}
275-
<a class="btn btn-sm btn-danger"
276-
href="{{ admin.generateObjectUrl('delete', object) }}">{{ 'link_delete'|trans({}, 'NetworkingInitCmsBundle') }}</a>
268+
{% if admin.id(object) %}
269+
<input type="submit" class="btn btn-sm btn-primary" name="btn_update_and_edit"
270+
value="{{ 'btn_update_and_edit_again'|trans({'%admin_label%': admin_label}, 'NetworkingInitCmsBundle') }}"/>
271+
<input type="submit" class="btn btn-sm btn-light" name="btn_update_and_list"
272+
value="{{ 'btn_update_and_return_to_list'|trans({'%admin_label%': admin_label}, 'NetworkingInitCmsBundle') }}"/>
273+
274+
{% if admin.hasroute('delete') and admin.isGranted('DELETE', object) and (object.isDeletable() is not defined or object.isDeletable == 1 ) %}
275+
{{ 'delete_or'|trans({}, 'SonataAdminBundle') }}
276+
<a class="btn btn-sm btn-danger"
277+
href="{{ admin.generateObjectUrl('delete', object) }}">{{ 'link_delete'|trans({}, 'NetworkingInitCmsBundle') }}</a>
278+
{% endif %}
277279
{% endif %}
278280
{% endif %}
279281
{% endblock formactions %}

0 commit comments

Comments
 (0)