The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ

Added a lastLoginAt field to the User entity

master
Polonkai Gergely 11 years ago
parent 26527d8057
commit adba578db8
  1. 2
      src/KekRozsak/FrontBundle/Entity/Role.php
  2. 29
      src/KekRozsak/FrontBundle/Entity/User.php
  3. 4
      src/KekRozsak/FrontBundle/Resources/config/doctrine/User.orm.yml
  4. 6
      src/KekRozsak/SecurityBundle/Resources/config/services.yml
  5. 28
      src/KekRozsak/SecurityBundle/Security/AuthSuccess.php

@ -142,4 +142,4 @@ class Role implements RoleInterface
{
return $this->name;
}
}
}

@ -307,4 +307,31 @@ class User implements UserInterface, AdvancedUserInterface
{
return ($this->accepted_by !== null);
}
}
/**
* @var datetime $last_login_at
*/
private $last_login_at;
/**
* Set last_login_at
*
* @param datetime $lastLoginAt
* @return User
*/
public function setLastLoginAt($lastLoginAt)
{
$this->last_login_at = $lastLoginAt;
return $this;
}
/**
* Get last_login_at
*
* @return datetime
*/
public function getLastLoginAt()
{
return $this->last_login_at;
}
}

@ -21,6 +21,10 @@ KekRozsak\FrontBundle\Entity\User:
display_name:
type: string(50)
nullable: false
last_login_at:
type: datetime
nullable: true
default: null
oneToMany:
articles:
targetEntity: Article

@ -1,6 +1,10 @@
parameters:
# kek_rozsak_security.example.class: KekRozsak\SecurityBundle\Example
services:
kek_rozsak_security.encoder.crypt:
class: KekRozsak\SecurityBundle\Service\CryptEncoder
security.authentication.success_handler:
class: KekRozsak\SecurityBundle\Security\AuthSuccess
public: false
arguments:
doctrine: @doctrine

@ -0,0 +1,28 @@
<?php
namespace KekRozsak\SecurityBundle\Security;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Doctrine\ORM\EntityManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Bridge\Doctrine\RegistryInterface;
class AuthSuccess implements AuthenticationSuccessHandlerInterface
{
private $doctrine;
public function __construct(RegistryInterface $doctrine)
{
$this->doctrine = $doctrine;
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
$user = $token->getUser();
$em = $this->doctrine->getEntityManager();
$user->setLastLoginAt(new \DateTime('now'));
$em->persist($user);
$em->flush();
}
}
Loading…
Cancel
Save