1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Use IsGranted in UserController

This commit is contained in:
Yassine Guedidi 2024-02-05 22:02:50 +01:00
parent 39c24ab6e2
commit beaca32493
9 changed files with 277 additions and 21 deletions

View file

@ -66,9 +66,13 @@
{{ form_widget(edit_form._token) }}
</form>
<p>
{{ form_start(delete_form) }}
<button {% if app.user.id == user.id %}disabled="disabled"{% endif %} onclick="return confirm('{{ 'user.form.delete_confirm'|trans|escape('js') }}')" type="submit" class="btn waves-effect waves-light red">{{ 'user.form.delete'|trans }}</button>
{{ form_end(delete_form) }}
{% if is_granted('DELETE', user) %}
{{ form_start(delete_form) }}
<button onclick="return confirm('{{ 'user.form.delete_confirm'|trans|escape('js') }}')" type="submit" class="btn waves-effect waves-light red">{{ 'user.form.delete'|trans }}</button>
{{ form_end(delete_form) }}
{% else %}
<button disabled="disabled" type="button" class="btn waves-effect waves-light red">{{ 'user.form.delete'|trans }}</button>
{% endif %}
</p>
<p><a class="waves-effect waves-light btn blue-grey" href="{{ path('user_index') }}">{{ 'user.form.back_to_list'|trans }}</a></p>
</div>

View file

@ -15,21 +15,23 @@
<p class="help">{{ 'user.description'|trans|raw }}</p>
</div>
<div class="col s6">
<div class="input-field">
<form name="search_users" method="GET" action="{{ path('user_index') }}">
{% if form_errors(searchForm) %}
<span class="black-text">{{ form_errors(searchForm) }}</span>
{% endif %}
{% if is_granted('LIST_USERS') %}
<div class="input-field">
<form name="search_users" method="GET" action="{{ path('user_index') }}">
{% if form_errors(searchForm) %}
<span class="black-text">{{ form_errors(searchForm) }}</span>
{% endif %}
{% if form_errors(searchForm.term) %}
<span class="black-text">{{ form_errors(searchForm.term) }}</span>
{% endif %}
{% if form_errors(searchForm.term) %}
<span class="black-text">{{ form_errors(searchForm.term) }}</span>
{% endif %}
{{ form_widget(searchForm.term, {'attr': {'autocomplete': 'off', 'placeholder': 'user.search.placeholder'}}) }}
{{ form_widget(searchForm.term, {'attr': {'autocomplete': 'off', 'placeholder': 'user.search.placeholder'}}) }}
{{ form_rest(searchForm) }}
</form>
</div>
{{ form_rest(searchForm) }}
</form>
</div>
{% endif %}
</div>
<table class="bordered">
@ -48,16 +50,20 @@
<td>{{ user.email }}</td>
<td>{% if user.lastLogin %}{{ user.lastLogin|date('Y-m-d H:i:s') }}{% endif %}</td>
<td>
<a href="{{ path('user_edit', {'id': user.id}) }}">{{ 'user.list.edit_action'|trans }}</a>
{% if is_granted('EDIT', user) %}
<a href="{{ path('user_edit', {'id': user.id}) }}">{{ 'user.list.edit_action'|trans }}</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<br />
<p>
<a href="{{ path('user_new') }}" class="waves-effect waves-light btn">{{ 'user.list.create_new_one'|trans }}</a>
</p>
{% if is_granted('CREATE_USERS') %}
<p>
<a href="{{ path('user_new') }}" class="waves-effect waves-light btn">{{ 'user.list.create_new_one'|trans }}</a>
</p>
{% endif %}
{% if users.getNbPages > 1 %}
{{ pagerfanta(users, 'default_wallabag') }}
{% endif %}