TYPO3 - What might cause that typoscript is rendering the wrong userID/userName of a current logged in / registered user?

184 views Asked by At

I have several registered user and parts (pages) of the site that can only be accessed by certain user groups / users.

When I want to catch more information about the current logged in user ... I send the uid and userame via typoscript to the frontend (fluid template) like this:

tyoscript:

lib.uid = TEXT
lib.uid.data = TSFE:fe_user|user|uid

lib.username = TEXT
lib.username.data = TSFE:fe_user|user|username

Main_layout.html:

<div class="container mainbox">
    <div itemscope itemtype="http://schema.org/Corporation">

    <f:render section="content" />

        <script>            
            var userID = '';            
            var userName = ''; 

            userID = '<f:cObject typoscriptObjectPath="lib.uid" />';            
            userName = '<f:cObject typoscriptObjectPath="lib.username" />';                 

            console.log(userID);            
            console.log(userName); 

        </script>

    </div>
</div><!-- /.container -->                  

But when testing different users ... I sometimes don't get the correct user information of the current logged in user. The information in the edit profile (with femanager) is correct ... but when looking in the console ... I sometimes get the information of the previous tested user.

What might causes this?

1

There are 1 answers

0
Riccardo De Contardi On

Could you add your TypoScript code? I used a COA_INT object on page and it seems to work:

page.3 = COA_INT
page.3 {
 10 = TEXT
 10.data = TSFE:fe_user|user|uid

 20 = TEXT
 20.data = TSFE:fe_user|user|username
}

I think you could write something like:

lib.myjscode = COA_INT
lib.myjscode {
    10 = TEXT
    10.value(
        var userID = '';            
        var userName = '';
    )
     20 = TEXT
     20.data = TSFE:fe_user|user|uid
     20.wrap = userID = '|';

     30 = TEXT
     30.data = TSFE:fe_user|user|username
     30.wrap = userName = '|';

     40 = TEXT
     40.value (
        console.log(userID);            
        console.log(userName); 
     )
    wrap = <script>|</script> 
    }        


page.3 < lib.myjscode