public function renderInstance($instanceId, $instanceConfig) { $error = null; $username = null; $view = parent::renderInstance($instanceId, $instanceConfig); $view->setVariables(['error' => $error, 'username' => $username]); if (!$this->postIsForThisPlugin()) { return $view; } $user = $this->getUser(); // Invalid User if (empty($user)) { $error = $instanceConfig['translate']['missing']; $view->setVariable('error', $error); return $view; } /** @var \Zend\Authentication\Result $authResult */ $authResult = $this->rcmUserService->authenticate($user); // Valid auth if ($authResult->isValid()) { $parms = array('request' => $this->getRequest(), 'response' => $this->getResponse()); $event = new Event('LoginSuccessEvent', $this, $parms); $eventManager = $this->getEventManager(); $eventManager->trigger($event); return $this->getResponse(); } // Invalid Auth if ($authResult->getCode() == Result::FAILURE_UNCATEGORIZED && !empty($this->config['rcmPlugin']['RcmLogin']['uncategorizedErrorRedirect'])) { return $this->redirect()->toUrl($this->config['rcmPlugin']['RcmLogin']['uncategorizedErrorRedirect']); } $error = $instanceConfig['translate']['invalid']; $view->setVariable('error', $error); return $view; }