2022-07-21

Get loggedin userinformation in extjs shopware backend

I know that I can access the javascript var userName everywhere in the extjs backend, cause its defined globally in the themes/Backend/ExtJs/backend/index/header.tpl, to get information about the logged in user. But is there a way to get userId or role of the user in some way (without ajax requests)?

//{block name="backend/order/view/list/list"}
//{$smarty.block.parent}
Ext.define('Shopware.apps.Test.view.List', {

    /**
     * Defines an override applied to a class.
     * @string
     */
    override: 'Shopware.apps.Order.view.list.List',

    getToolbar: function() {

        // get this
        var me = this;

        // get parent action column
        var result = me.callParent( arguments );

        console.log(userName);
    },
});
//{/block}
{block name="backend/base/header/javascript" append}
<script type="text/javascript">

    var currentTabState = 'active';
    window.addEventListener('blur', function () {
        currentTabState = 'inactive';
    });

    window.addEventListener('focus', function () {
        currentTabState = 'active';
    });

    var userName = '{$user->name}',
        maxParameterLength = '{$maxParameterLength}';


No comments:

Post a Comment