added API tokens, deprecate API passwords (#4637)

This commit is contained in:
Kevin Papst
2024-04-05 23:51:16 +02:00
committed by GitHub
parent dd51c8dfba
commit afe0656502
60 changed files with 889 additions and 624 deletions

View File

@@ -0,0 +1,47 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* 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\AccessToken;
use App\Entity\User;
use Doctrine\ORM\EntityRepository;
/**
* @extends EntityRepository<AccessToken>
*/
class AccessTokenRepository extends EntityRepository
{
public function findByToken(string $token): ?AccessToken
{
return $this->findOneBy(['token' => $token]);
}
/**
* @return array<AccessToken>
*/
public function findForUser(User $user): array
{
return $this->findBy(['user' => $user]);
}
public function saveAccessToken(AccessToken $accessToken): void
{
$entityManager = $this->getEntityManager();
$entityManager->persist($accessToken);
$entityManager->flush();
}
public function deleteAccessToken(AccessToken $accessToken): void
{
$entityManager = $this->getEntityManager();
$entityManager->remove($accessToken);
$entityManager->flush();
}
}