Browse Source

Adding LoginListener file a hook when the 'login_as' process is called. (this one contains the file!)

Julio Montoya 11 years ago
parent
commit
b421bb4cea
1 changed files with 24 additions and 0 deletions
  1. 24 0
      src/ChamiloLMS/Component/Auth/LoginListener.php

+ 24 - 0
src/ChamiloLMS/Component/Auth/LoginListener.php

@@ -0,0 +1,24 @@
+<?php
+namespace ChamiloLMS\Component\Auth;
+
+use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
+use Symfony\Component\Security\Http\Event\SwitchUserEvent;
+
+class LoginListener
+{
+    /**
+     * Fired on switch user, you can remove attributes or whatever you want here.
+     * @param SwitchUserEvent $event
+     */
+    public function onSecuritySwitchUser(SwitchUserEvent $event)
+    {
+        /** @var \Entity\User $user */
+        $user = $event->getTargetUser();
+        /*var_dump($user );
+        var_dump($event->getRequest()->getUser());
+        */
+
+        $session = $event->getRequest()->getSession();
+        //$session->remove('partThatShouldNotCarryOver');
+    }
+}