What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi community, first time poster here. Is there an easy way of knowing wether the logged in customer

UKS668UPP
UKS668UPP Posts: 13 🧑🏻‍🚀 - Cadet

Hi community, first time poster here.

Is there an easy way of knowing wether the logged in customer is being impersonated by an agent or not?
AgentClient->isLoggedIn will return false based on my tests.

Thanks :)

Comments

  • rshopin
    rshopin Senior Solution Architect Sprykee Posts: 32 🧑🏻‍🚀 - Cadet
    edited March 2020

    @UKS668UPP
    In Twig or PHP? If in Twig, use:

    {% if is_granted('ROLE_PREVIOUS_ADMIN') %}
    

    if in PHP see \SprykerShop\Yves\AgentPage\Plugin\FixAgentTokenAfterCustomerAuthenticationSuccessPlugin::fixAgentToken

    Also see \SprykerShop\Yves\CustomerPage\Security\Customer::getRoles

    iterate over roles and check if customer belong to role which is instance of \Symfony\Component\Security\Core\Role\SwitchUserRole

  • UKS668UPP
    UKS668UPP Posts: 13 🧑🏻‍🚀 - Cadet

    Hey Roman 😄 I was looking for way to do it in PHP. Thanks