Possible solution would be to have a route event handler, where you set user credentials:
class Module
{
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()
->getEventManager ();
$eventManager->attach (
MvcEvent::EVENT_ROUTE,
function (MvcEvent $e)
{
$auth = $e->getApplication()
->getServiceManager()
->get('AuthService');
$e->setParam('userinfo', $auth->getUserInfo());
// update
$layout = $e->getViewModel();
$layout->userinfo = $auth->getUserInfo();
});
}
and then access then in the controller like this:
class IndexController extends AbstractActionController
{
public function indexAction ()
{
$this->getEvent()->getParam('userinfo');