<?php
namespace App\Controller;
use App\Entity\User;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\User\UserInterface;
class SecurityPageController extends AbstractController
{
#[Route('/securite', name: 'app_security', methods: ['GET'])]
public function index(UserInterface $user): Response
{
$city = null;
/**
* @var User $user
*/
if (!$user->getTrackings()->isEmpty() && $last = $user->getTrackings()->last()) {
$city = $last->getCity();
}
return $this->render('security/security-page.html.twig', [
'ip' => $user->getLastKnownIp(),
'lastConnection' => $user->getLastConnection(),
'city' => $city,
]);
}
}