OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

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 7 years, 8 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #34221

    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
  • #34222

    Mike Kudelya
    Participant

    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.

    #34223

    Mike Kudelya
    Participant

    Here is my security.yml

    #34224

    Mike Kudelya
    Participant

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

    #34225

    Mike Kudelya
    Participant

    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

    #34226

    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)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top