diff --git a/datamodels/2.x/itop-portal-base/portal/src/EventListener/UserProvider.php b/datamodels/2.x/itop-portal-base/portal/src/EventListener/UserProvider.php index df2dd6d2b..0f77f7e78 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/EventListener/UserProvider.php +++ b/datamodels/2.x/itop-portal-base/portal/src/EventListener/UserProvider.php @@ -29,6 +29,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Exception\HttpException; use UserRights; +use utils; /** * Class UserProvider @@ -91,6 +92,9 @@ class UserProvider implements ContainerAwareInterface } $this->oContainer->set('combodo.current_user', $oUser); + // User allowed to log off or not + $this->oContainer->set('combodo.current_user.can_logoff', utils::CanLogOff()); + // Allowed portals $aAllowedPortals = UserRights::GetAllowedPortals(); diff --git a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig index e58e36a8e..72208ebe0 100644 --- a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig +++ b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig @@ -3,11 +3,13 @@ {% if app['combodo.current_user'] is defined and app['combodo.current_user'] is not null %} {% set bUserConnected = true %} + {% set bUserCanLogOff = app['combodo.current_user.can_logoff'] %} {% set sUserFullname = app['combodo.current_user'].Get('first_name') ~ ' ' ~ app['combodo.current_user'].Get('last_name') %} {% set sUserEmail = app['combodo.current_user'].Get('email') %} {% set sUserPhotoUrl = app['combodo.current_contact.photo_url'] %} {% else %} {% set bUserConnected = false %} + {% set bUserCanLogOff = false %} {% set sUserFullname = '' %} {% set sUserEmail = '' %} {% set sUserPhotoUrl = app['combodo.portal.base.absolute_url'] ~ 'img/user-profile-default-256px.png' %} @@ -230,11 +232,13 @@
  • {{ aPortal.label|dict_s }}
  • {% endif %} {% endfor %} - {# We display the separator only if the user has more then 1 portal. Meaning default portal + console or several portal at least #} - {% if app['combodo.current_user.allowed_portals']|length > 1 %} - - {% endif %} -
  • {{ 'Brick:Portal:UserProfile:Navigation:Dropdown:Logout'|dict_s }}
  • + {% if bUserCanLogOff %} + {# We display the separator only if the user has more then 1 portal. Meaning default portal + console or several portal at least #} + {% if app['combodo.current_user.allowed_portals']|length > 1 %} + + {% endif %} +
  • {{ 'Brick:Portal:UserProfile:Navigation:Dropdown:Logout'|dict_s }}
  • + {% endif %} {% endif %} @@ -269,11 +273,13 @@
  • {{ aPortal.label|dict_s }}
  • {% endif %} {% endfor %} - {# We display the separator only if the user has more then 1 portal. Meaning default portal + console or several portal at least #} - {% if app['combodo.current_user.allowed_portals']|length > 1 %} - - {% endif %} -
  • {{ 'Brick:Portal:UserProfile:Navigation:Dropdown:Logout'|dict_s }}
  • + {% if bUserCanLogOff %} + {# We display the separator only if the user has more then 1 portal. Meaning default portal + console or several portal at least #} + {% if app['combodo.current_user.allowed_portals']|length > 1 %} + + {% endif %} +
  • {{ 'Brick:Portal:UserProfile:Navigation:Dropdown:Logout'|dict_s }}
  • + {% endif %}