Private
Public Access
1
0

chg: usr: add modern Webauthn authentication #4

This commit is contained in:
2026-04-12 15:19:03 +02:00
parent acbe9c7f63
commit 0144a3953c
23 changed files with 2845 additions and 13 deletions

View File

@@ -0,0 +1,56 @@
<?php declare(strict_types=1);
/**
* This file is part of the SplendidBear Websites' projects.
*
* Copyright (c) 2026 @ www.splendidbear.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Repository;
use App\Entity\User;
use App\Entity\WebAuthnCredential;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<WebAuthnCredential>
*
* @method WebAuthnCredential|null find($id, $lockMode = null, $lockVersion = null)
* @method WebAuthnCredential|null findOneBy(array $criteria, array $orderBy = null)
* @method WebAuthnCredential[] findAll()
* @method WebAuthnCredential[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class WebAuthnCredentialRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, WebAuthnCredential::class);
}
public function findByUser(User $user): array
{
return $this->findBy(['user' => $user], ['createdAt' => 'DESC']);
}
public function countByUser(User $user): int
{
return $this->count(['user' => $user]);
}
public function deleteByIdAndUser(int $id, User $user): void
{
$qb = $this->createQueryBuilder('wac');
$qb
->delete()
->where($qb->expr()->eq('wac.id', ':id'))
->andWhere($qb->expr()->eq('wac.user', ':user'))
->setParameter('id', $id)
->setParameter('user', $user)
->getQuery()
->execute();
}
}