add optional impersonate feature (if firewall option switch_user is true)

This commit is contained in:
Tchama 2019-05-16 14:04:41 +02:00
parent c1b8de4ee5
commit 7bcb80be54
4 changed files with 44 additions and 10 deletions

View File

@ -50,3 +50,7 @@ Version 1.5.7
- add css layout for boxes ;
- collect supplementary query parameters in SearchController ;
Branch amli_impersonate
=======================
- add optionnal impersonate feature (if firewall option switch_user is true) ;

View File

@ -219,4 +219,7 @@ Your administrator: Votre administrateur
Recover your password: Regénération du mot de passe
New password set: Le nouveau mot de passe est enregistré
Your password has been set.: Votre mot de passe a été changé.
Log in with your new password: Connectez-vous avec votre nouveau mot de passe
Log in with your new password: Connectez-vous avec votre nouveau mot de passe
# impersonate
Exit impersonation: Retour Administrateur

View File

@ -19,22 +19,40 @@
<li class="nav-link2 user-menu">
<div class="li-content">
<a href="javascript:void(0)" style="font-size: 0.8em; font-family: 'Open Sans'; font-weight:300;">
{{ 'Welcome' | trans }}<br/>
<b>{{ app.user.username }}{{ render(controller('ChillMainBundle:UI:showNotificationUserCounter')) }}</b>
<b>{{ app.user.username }}{{ render(controller('ChillMainBundle:UI:showNotificationUserCounter')) }}</b>
{% if is_granted('ROLE_PREVIOUS_ADMIN') %}
<i class="fa fa-wrench fa-lg" title="Impersonate mode"></i>
{% endif %}
</a>
</div>
<ul class="submenu width-11-em user-menu-list" style="padding-left: 0; padding-right: 0; background-color:transparent;">
{% for menu in menus %}
<li style="display:block; background-color: #333333; padding-left:1.5em; border-bottom:1px; border-bottom: 1px solid #FFF;padding-top:0; padding-bottom:0;">
<div style="margin-bottom:2px;">
<div style="font-family: 'Open Sans'; font-weight:300; font-size: 0.75em; text-align:left; height: 46px; display:inline-block; width: calc(100% - 5em - 1px); vertical-align:top;">
<div style="font-family: 'Open Sans'; font-weight:300; font-size: 0.75em; text-align:left; height: 46px; display:inline-block; width: calc(100% - 5em - 1px); vertical-align:top;">
{# Impersonate case logout #}
{% if is_granted('ROLE_PREVIOUS_ADMIN') and menu.name == 'Logout' %}
<a href="{{ path('chill_main_homepage', {'_switch_user': '_exit'}) }}">
{{ 'Exit impersonation'|trans }}
</a>
{% else %}
<a href="{{ menu.uri }}">{{ menu.label|trans }}</a>
</div>
<div style="background-color: #333333; text-align:center;width: 2em; margin-left:-0.15em; font-size:1.5em; color:#FFF; height: 46px; display:inline-block; vertical-align:top;float:right">{% spaceless %}
{% if menu.extras.icon is defined %}
<i class="fa fa-{{ menu.extras.icon }}"></i>
{% endif %}
{% endspaceless %}</div>
{% endif %}
</div>
<div style="background-color: #333333; text-align:center;width: 2em; margin-left:-0.15em; font-size:1.5em; color:#FFF; height: 46px; display:inline-block; vertical-align:top;float:right">{% spaceless %}
{% if menu.extras.icon is defined %}
<i class="fa fa-{{ menu.extras.icon }}"></i>
{% endif %}
{% endspaceless %}</div>
</div>
</li>
{% endfor %}

View File

@ -27,6 +27,14 @@
<li>
<a href="{{ path('admin_user_edit_password', { 'id' : entity.id }) }}">{{ 'Edit password'|trans }}</a>
</li>
{% if is_granted('ROLE_ALLOWED_TO_SWITCH') %}
<li>
<a href="{{ path('chill_main_homepage', {'_switch_user': entity.username }) }}">
{{ 'Impersonate'|trans }}
</a>
</li>
{% endif %}
</ul>
</td>
</tr>
@ -34,11 +42,12 @@
</tbody>
</table>
<ul>
<ul>
<li>
<a href="{{ path('admin_user_new') }}">
{{ 'Add a new user'|trans|capitalize }}
</a>
</li>
</ul>
{% endblock admin_content %}