I have an custom controller API which I have to keep anonymous for business reasons but I send 1 of user ids in the body payload. Then in respective service I do authentication.begin as that user. If I see user in user session its correct and then I create the entity.
But I have a entity listener for on before insert where I need to fetch that user from user session source but I still get anonymous there. I started noticing it recently because of some transaction changes I made but cannot point out why entity listener is not in same transaction.