diff --git a/src/KekRozsak/FrontBundle/Form/Type/ForumPostType.php b/src/KekRozsak/FrontBundle/Form/Type/ForumPostType.php index 7a8fdb1..b266f8e 100644 --- a/src/KekRozsak/FrontBundle/Form/Type/ForumPostType.php +++ b/src/KekRozsak/FrontBundle/Form/Type/ForumPostType.php @@ -17,10 +17,6 @@ class ForumPostType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('createdAt', 'hidden', array( - 'label' => 'Időpont', - 'data' => new \DateTime('now') - )); $builder->add('text', null, array( 'label' => ' ', )); diff --git a/src/KekRozsak/SecurityBundle/Resources/config/services.xml b/src/KekRozsak/SecurityBundle/Resources/config/services.xml index f0a54ce..286e69c 100644 --- a/src/KekRozsak/SecurityBundle/Resources/config/services.xml +++ b/src/KekRozsak/SecurityBundle/Resources/config/services.xml @@ -4,8 +4,9 @@ - + + diff --git a/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php b/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php index d69be21..b2e6f81 100644 --- a/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php +++ b/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php @@ -6,6 +6,7 @@ use Doctrine\ORM\EntityManager; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Bridge\Doctrine\RegistryInterface; +use Symfony\Component\Security\Core\Event\AuthenticationEvent; class AuthSuccess implements AuthenticationSuccessHandlerInterface { @@ -16,6 +17,15 @@ class AuthSuccess implements AuthenticationSuccessHandlerInterface $this->doctrine = $doctrine; } + public function onSecurityAuthenticationSuccess(AuthenticationEvent $event) + { + $user = $event->getAuthenticationToken()->getUser(); + $em = $this->doctrine->getEntityManager(); + $user->setLastLoginAt(new \DateTime('now')); + $em->persist($user); + $em->flush(); + } + public function onAuthenticationSuccess(Request $request, TokenInterface $token) { $user = $token->getUser();