Service Portal Header - user.logged_in always has True value??

ASA5
Kilo Sage

Hello,

In Service Portal Header there is somme conditions on this variable "user.logged_in" to show or hide specific content :

  1. <ul ng-if="::user.logged_in" class="nav navbar-nav">  
  2.               <!-- chat, avatar, and logout -->  
  3.               <li ng-if="::data.connect_support_queue_id"><a href ng-click="openPopUp()">${Live Chat}</a></li>  
  4.               <li class="dropdown hidden-xs">  
  5.                   <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">  
  6.                       <span class="navbar-avatar"><sn-avatar class="avatar-small-medium" primary="userID" /></span>  
  7.                       <span class="visible-lg-inline">{{::user.name}}</span>  
  8.                   </a>  
  9.                   <ul class="dropdown-menu">  
  10.                       <li><a ng-href="?id=user_profile&sys_id={{::user.sys_id}}">${Profile}</a></li>  
  11.                       <li><a href="{{::portal.logoutUrl}}">${Logout}</a></li>  
  12.                   </ul>  
  13.               </li>  
  14.               <li class="visible-xs-block"><a ng-href="?id=user_profile&sys_id={{::user.sys_id}}">
  15.                   <span class="navbar-avatar"><sn-avatar class="avatar-small-medium" primary="userID" /></span>{{::user.name}}</a></li>  
  16.               <li class="visible-xs-block"><a href="{{::portal.logoutUrl}}">${Logout}</a></li>  
  17.           </ul>

But the content is always shown   and when I check the value of   this variable user.logged_in i see that it is always on True, although the user is logged out.

I checked also the controller of the header and the variable user.logged_in is not defined there.

Does any one faced this kind of issue before ??

thank you !!

2 REPLIES 2

Jack
Tera Guru

Hi Abdel Moumene,



I have the same this issue when I try to use the customize login page.


And this is my code was changed for header widget:


(replace user.logged_in by user.sys_id )



<ul ng-if="::(!user.sys_id && page.id != portal.login_page_dv && !data.hasLogin)" class="nav navbar-nav">



      <li>


              <a href ng-click="openLogin()">${Login}</a>


      </li>


</ul>


<ul ng-if="::user.sys_id" class="nav navbar-nav">


      <!-- chat, avatar, and logout -->


      <li ng-if="::data.connect_support_queue_id">


              <a href ng-click="openPopUp()">${Live Chat}</a>


      </li>


      <li class="dropdown hidden-xs">


              <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">


                      <span class="navbar-avatar">


                              <sn-avatar class="avatar-small-medium" primary="userID" />


                      </span>


                      <span class="visible-lg-inline">{{::user.name}}</span>


              </a>


              <ul class="dropdown-menu">


                      <li>


                              <a ng-href="?id=user_profile&sys_id={{::user.sys_id}}">${Profile}</a>


                      </li>


                      <li>


                              <a href="{{::portal.logoutUrl}}">${Logout}</a>


                      </li>


              </ul>


      </li>


      <li class="visible-xs-block">


              <a ng-href="?id=user_profile&sys_id={{::user.sys_id}}">


                      <span class="navbar-avatar">


                              <sn-avatar class="avatar-small-medium" primary="userID" />


                      </span>{{::user.name}}              


              </a>


      </li>


      <li class="visible-xs-block">


              <a href="{{::portal.logoutUrl}}">${Logout}</a>


      </li>


</ul>



It's work for me. You can try it.


Hi Jack,



Thank you for your proposition i guess it will work as the user sys_id doesn't exist when the user is not logged in.



Actually I have resolved the issue by using gs.isLoggedIn() function in the server script :



  1. //Server Script
  2. //check if the user is logged in  
  3. data.isUserLoggedIn= gs.isLoggedIn();  


Then in the Body Html Template I replaced user.logged_in by data.isUserLoggedIn.



  1. //Body Html template  
  2. <ul ng-if="::data.isUserLoggedIn" class="nav navbar-nav">


The second way if you want to keep using user.logged_in is to set its value on the controller :



  1. //Controller
  2. $scope.user.logged_in = $scope.data.isUserLoggedIn;


  1. //Body Html template
  2. <ul ng-if="::user.logged_in" class="nav navbar-nav">