From a9f8dcc5e8d1a4dc11ab4764952a878d813dc671 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Mon, 11 Mar 2024 21:13:09 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B07122=20N=C2=B04164=20-=20Portal:=20Hide?= =?UTF-8?q?=20log=20off=20button=20when=20user=20can't=20actually=20log=20?= =?UTF-8?q?off=20(eg.=20SSO=20using=20SAML=20or=20other=20providers)=20(#5?= =?UTF-8?q?99)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * N°7122 N°4164 - Portal: Hide log off button when user can't actually log off (eg. SSO using SAML or other providers) * N°7122 - Fix typo Co-authored-by: Thomas Casteleyn --------- Co-authored-by: Thomas Casteleyn --- .../portal/src/EventListener/UserProvider.php | 4 +++ .../portal/templates/layout.html.twig | 26 ++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) 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 df2dd6d2b0..0f77f7e78b 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 e58e36a8e4..72208ebe0a 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 %}