示例#1
0
 public function onKernelLogOk(AuthenticationEvent $event)
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $useragent = $_SERVER['HTTP_USER_AGENT'];
     $token = $event->getAuthenticationToken();
     $user = $token->getUser();
     $session = new Session();
     if (gettype($user) != 'string') {
         $log = new Log();
         $log->setUser($user);
         $log->setIp($ip);
         $log->setEtat(true);
         $log->setUseragent($useragent);
         $this->em->persist($log);
         $user->setLogged(true);
         $user->setTimeUpdate(new \DateTime());
         $user->setLogIn($log);
         $this->em->flush();
         $session->set('log', $log->getId());
     }
 }
 /**
  * {@inheritDoc}
  */
 public function setIp($ip)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setIp', [$ip]);
     return parent::setIp($ip);
 }