* @category Class * @license https://www.gnu.org/licenses/lgpl-3.0.en.html GNU Lesser General Public License * @link www.splendidbear.org * @since 2026. 04. 11. */ #[AsController] class ProfileController extends AbstractController { public function __construct( private readonly PlayedGameRepository $repo, private readonly WebAuthnService $webAuthnService ) { } #[Route('/profile', name: 'MineSeekerBundle_profile')] public function index(): Response { /** @var User $user */ $user = $this->getUser(); $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); return $this->render('Security/profile.html.twig', [ 'stats' => [ 'total' => $this->repo->countFinishedForUser($user), 'wins' => $this->repo->countWinsForUser($user), 'losses' => $this->repo->countLossesForUser($user), 'bombs' => $this->repo->countBombsForUser($user), ], 'recent' => $this->repo->findRecentFinishedForUser($user), ]); } #[Route('/profile/security', name: 'MineSeekerBundle_profile_security')] public function security(): Response { /** @var User $user */ $user = $this->getUser(); $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED'); $credentials = $this->webAuthnService->getCredentialsForUser($user); $credentialsData = array_map(fn ($cred) => [ 'id' => $cred->getId(), 'credentialName' => $cred->getCredentialName(), 'createdAt' => $cred->getCreatedAt()?->format('Y-m-d H:i:s'), 'lastUsedAt' => $cred->getLastUsedAt()?->format('Y-m-d H:i:s'), 'isBackupEligible' => $cred->isBackupEligible(), 'isBackupAuthenticated' => $cred->isBackupAuthenticated(), ], $credentials); return $this->render('Security/profile_security.html.twig', [ 'credentials' => $credentialsData, ]); } }