Skip to content

System user is resolved instead of actual user #3603

@SimonCremer

Description

@SimonCremer

If you want to request user information in an extension, the system user is resolved instead of the actual user.
You can use one of the studio examples to reproduce the issue. For example the left sidebar one.

If you change the extension with the following code. You will get the system user.

import {type AbstractModule, container} from '@pimcore/studio-ui-bundle'
import {serviceIds} from '@pimcore/studio-ui-bundle/app'
import {componentConfig, type ComponentRegistry} from '@pimcore/studio-ui-bundle/modules/app'
import {ExampleButton} from '../components/example-button'
import { getCurrentUser } from "@pimcore/studio-ui-bundle/modules/auth"

export const LeftSidebarExtension: AbstractModule = {
    onInit: (): void => {
        const componentRegistry = container.get<ComponentRegistry>(serviceIds['App/ComponentRegistry/ComponentRegistry'])

        const user = getCurrentUser();
        console.log("user in extension", user);

        componentRegistry.registerToSlot(
            componentConfig.leftSidebar.slot.name,
            {
                name: 'exampleButton',
                component: ExampleButton,
                priority: 101
            }
        )
    }
}

Changing the code in the same way in the component will get you the actual user.

I want to add a sidebar button for admin users only, how can I achieve that without knowing the acutal user.

Do i have to choose another approach, or is it a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Affected capability

    None yet

    Platform Version

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions