ssossossossosso

Forums

Forums OroPlatform OroPlatform – Programming Questions How to switch user (ImpersonationToken)

This topic contains 5 replies, has 2 voices, and was last updated by  cardiac 1 year, 6 months ago.

  • Creator
    Topic
  • #28740

    cardiac
    Participant

    Hi,

    I wanted to activate the symfony switch user implementation.

    security.yml

    But if I try to switch it I see an error:

    Fatal error: Call to undefined method

    Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::getOrganizationContext() in /var/www/vhosts/orocrm/vendor/oro/platform/src/Oro/Bundle/DashboardBundle/Model/Manager.php on line 232

    I then found the ImpersonationToken which implements the OrganizationContextTokenInterface and should therefor work fine. But I haven’t found how to make use of it.

    Can you help me with the switch user case?

    Thanks and

    best regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #28741

    Mike Kudelya
    Moderator

    Hi,

    Unfortunately native orocrm doesn’t support this feature, because it uses Symfony SwitchUserListener, which uses UserPasswordToken, which doesn’t know about getOrganizationContext() function. Quite complicated. But i have created custom code, which allows use user switch. I didn’t test it enough, so use it as good example.

    #28742

    Mike Kudelya
    Moderator

    Here is my security.yml

    #28743

    Mike Kudelya
    Moderator

    I had to copy the entire file because original SwitchUserListener.php too closed (many private properties)

    #28744

    Mike Kudelya
    Moderator

    This is my custom UsernamePasswordOrganizationToken.php which is using by listener. I was thinking how to make it better and wrapped serialized data into base64, because i had some problems with || gluing in parent class.

    And last php file is token factory.

    service.yml

    #28745

    cardiac
    Participant

    Thank you Mike for the example. I will update here if I could use it.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.