public function logout() { Events::dispatch(FrameworkEvents::SESSION_DESTROY, new FrameworkEvent()); session_regenerate_id(true); $this->loadAnonymous(); return true; }
public function deleteUser() { $this->user = new User($this->request->id); if ($this->user->delete()) { FlashMessage::success(Strings::GELOESCHT); // TODO: Das sollte man vielleicht in der Entity-Klasse machen $event = new EntityEvent(); $event->setEntity($this->user); Events::dispatch(FrameworkEvents::ENTITY_AFTER_DELETE, $event); } else { FlashMessage::danger(Strings::NICHT_GELOESCHT); } }
/** * Wird aufgerufen, wenn das Modul zum ersten Mal innerhalb * eines Requests angefragt wurde. */ public function init() { Events::dispatch(ModuleEvents::MODULE_INIT, new ModuleInitEvent($this)); }
/** * Aktionen, die nach dem Beenden eines Requests ausgeführt werden * @param Request $request * @param Response|null $response */ protected function postRequest(Request $request, $response) { Events::dispatch(FrameworkEvents::REQUEST_AFTER, new RequestEvent($request)); }
use NewFrontiers\Framework\Core\Application; use NewFrontiers\Framework\Events\FrameworkEvents; use Nostromo\Contracts\Facades\Events; use Nostromo\Contracts\Facades\Logging; use Nostromo\Contracts\Facades\Profiler; use Nostromo\Contracts\Facades\Security; use Symfony\Component\EventDispatcher\Event; Profiler::startSection('initApplication'); // Listener, der als Login-Gate fungiert // TODO: In eigene Klasse Events::addListener(FrameworkEvents::REQUEST_BEFORE, function (\NewFrontiers\Framework\Events\RequestEvent $event) { $request = $event->getRequest(); // Nur Admin schützen if (!$request->admin) { return; } // API ausnhemen (pauschal) if ($request->module == 'api' || $request->module == 'Api') { return; } $allowedActions = array('showLogin', 'login', 'loginFailure', 'logout', 'password', 'doPassword', 'reset', 'doReset'); if (!Security::isAuthenticated() && !in_array($request->action, $allowedActions)) { $request->followUpModule = $request->module; $request->followUpAction = $request->action; $request->module = 'defaultMod'; $request->action = 'showLogin'; Logging::warning('Action not allowed. User was sent to Login-Screen'); } else { } }); Profiler::endSection('initApplication');