/** * Clears the session variable namespace used by the Users module. * * Triggered by the 'user.logout.succeeded' and 'frontcontroller.exception' events. * * This is to ensure no leakage of authentication information across sessions or between critical * errors. This prevents, for example, the login process from becoming confused about its state * if it detects session variables containing authentication information which might make it think * that a re-attempt is in progress. * * @param GenericEvent $event The event that triggered this handler. * * @return void */ public static function clearUsersNamespaceListener(GenericEvent $event) { $eventName = $event->getName(); $modinfo = $event->hasArgument('modinfo') ? $event->getArgument('modinfo') : array(); $doClear = $eventName == 'user.logout.succeeded' || $eventName == 'frontcontroller.exception' && isset($modinfo) && is_array($modinfo) && !empty($modinfo) && !isset($modinfo['name']) && $modinfo['name'] == self::$modname; if ($doClear) { $container = \ServiceUtil::getManager(); $session = $container->get('session'); $session->clearNamespace('Zikula_Users'); //Do not setNotified. Not handling the exception, just reacting to it. } }
/** * Dynamically add menu links to administration for system services. * * Listens for 'module_dispatch.postexecute' events. * * @param GenericEvent $event The event handler. * * @return void */ public function addServiceLink(GenericEvent $event) { // check if this is for this handler if (!($event['modfunc'][1] == 'getlinks' && $event['type'] == 'admin' && $event['api'] == true)) { return; } // notify EVENT here to gather any system service links $args = array('modname' => $event->getArgument('modname')); $localevent = new GenericEvent($event->getSubject(), $args); $this->dispatcher->dispatch('module_dispatch.service_links', $localevent); $sublinks = $localevent->getData(); if (!empty($sublinks)) { $event->data[] = array('url' => \ModUtil::url($event['modname'], 'admin', 'moduleservices'), 'text' => __('Services'), 'class' => 'z-icon-es-gears', 'links' => $sublinks); } }