Skip to content

Commit

Permalink
Rename Tokens => Token
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jul 19, 2023
1 parent 2d95795 commit dba7088
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions application/src/Controller/BackOfficeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Entity\RoomMember;
use App\Entity\Room;
use App\Entity\ThreePID;
use App\Entity\Tokens;
use App\Entity\Token;
use App\Entity\User;
use App\Traits\GeneralTrait;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
Expand Down Expand Up @@ -46,11 +46,11 @@ public function backOfficeCreateAdmin(string $serverID, Request $request) : Json
}

// Process tokens.
$token = $entityManager->getRepository(Tokens::class)
$token = $entityManager->getRepository(Token::class)
->findOneBy(['userid' => $user->getId()]);
if (!$token) {
// New user, or existing user without any associated Tokens.
$token = new Tokens();
$token = new Token();
$token->setAccesstoken($this->generateToken('access-token'));
$token->setRefreshtoken($this->generateToken('refresh-token'));
$token->setExpiresinms();
Expand Down
4 changes: 2 additions & 2 deletions application/src/Controller/MatrixController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Entity\Password;
use App\Entity\Room;
use App\Entity\RoomMember;
use App\Entity\Tokens;
use App\Entity\Token;
use App\Entity\User;
use App\Traits\GeneralTrait;
use App\Traits\MatrixSynapseTrait;
Expand Down Expand Up @@ -137,7 +137,7 @@ public function login(string $serverID, Request $request): JsonResponse {

// Check if user with its password is found.
if ($user && $password) {
$token = $entityManager->getRepository(Tokens::class)->findOneBy(['userid' => $user->getId()]);
$token = $entityManager->getRepository(Token::class)->findOneBy(['userid' => $user->getId()]);

// Assign client server id if the server id is NULL.
if (is_null($token->getServerid())) {
Expand Down
6 changes: 3 additions & 3 deletions application/src/Controller/SynapseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use App\Entity\ThreePID;
use App\Entity\RoomMember;
use App\Entity\Room;
use App\Entity\Tokens;
use App\Entity\Token;
use App\Traits\GeneralTrait;
use App\Traits\MatrixSynapseTrait;

Expand Down Expand Up @@ -170,10 +170,10 @@ private function upsertUser(string $serverID, string $userID, Request $request,
}

// Process access tokens.
$token = $entityManager->getRepository(Tokens::class)->findOneBy(['userid' => $user->getId()]);
$token = $entityManager->getRepository(Token::class)->findOneBy(['userid' => $user->getId()]);
if (!$token) {
// New user, or existing user without any associated Tokens.
$token = new Tokens();
$token = new Token();
$token->setAccesstoken($this->generateToken('access-token'));
$token->setRefreshtoken($this->generateToken('refresh-token'));
$token->setServerid($serverID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace App\Entity;

use App\Repository\TokensRepository;
use App\Repository\TokenRepository;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass=TokensRepository::class)
* @ORM\Entity(repositoryClass=TokenRepository::class)
*/
class Tokens
class Token
{
/**
* @ORM\Id
Expand Down
6 changes: 3 additions & 3 deletions application/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class User
private $passwordpattern;

/**
* @ORM\OneToMany(targetEntity=Tokens::class, mappedBy="userid", cascade={"persist", "remove"})
* @ORM\OneToMany(targetEntity=Token::class, mappedBy="userid", cascade={"persist", "remove"})
*/
private $tokens;

Expand Down Expand Up @@ -236,14 +236,14 @@ public function removeExternalid(ExternalId $externalid): self
}

/**
* @return Collection<Tokens>
* @return Collection<Token>
*/
public function getTokens(): Collection
{
return $this->tokens;
}

public function addToken(Tokens $token): self
public function addToken(Token $token): self
{
$token->setUserid($this);
$this->tokens->add($token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@

namespace App\Repository;

use App\Entity\Tokens;
use App\Entity\Token;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Doctrine\Persistence\ManagerRegistry;

/**
* @extends ServiceEntityRepository<Tokens>
* @extends ServiceEntityRepository<Token>
*
* @method Tokens|null find($id, $lockMode = null, $lockVersion = null)
* @method Tokens|null findOneBy(array $criteria, array $orderBy = null)
* @method Tokens[] findAll()
* @method Tokens[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
* @method Token|null find($id, $lockMode = null, $lockVersion = null)
* @method Token|null findOneBy(array $criteria, array $orderBy = null)
* @method Token[] findAll()
* @method Token[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class TokensRepository extends ServiceEntityRepository
class TokenRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Tokens::class);
parent::__construct($registry, Token::class);
}

/**
* @throws ORMException
* @throws OptimisticLockException
*/
public function add(Tokens $entity, bool $flush = true): void
public function add(Token $entity, bool $flush = true): void
{
$this->_em->persist($entity);
if ($flush) {
Expand All @@ -39,7 +39,7 @@ public function add(Tokens $entity, bool $flush = true): void
* @throws ORMException
* @throws OptimisticLockException
*/
public function remove(Tokens $entity, bool $flush = true): void
public function remove(Token $entity, bool $flush = true): void
{
$this->_em->remove($entity);
if ($flush) {
Expand Down
4 changes: 2 additions & 2 deletions application/src/Service/ApiCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use App\Entity\Tokens;
use App\Entity\Token;
use Doctrine\ORM\EntityManagerInterface;

class ApiCheck extends AbstractController {
Expand Down Expand Up @@ -67,7 +67,7 @@ public function checkAuth($request): array
*/
private function isValidAuthToken(string $authToken): ?object
{
return $this->entityManger->getRepository(Tokens::class)->findOneBy(['accesstoken' => $authToken]);
return $this->entityManger->getRepository(Token::class)->findOneBy(['accesstoken' => $authToken]);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions application/src/Traits/MatrixSynapseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use App\Entity\Room;
use App\Entity\RoomMember;
use App\Entity\Tokens;
use App\Entity\Token;
use App\Entity\User;

trait MatrixSynapseTrait {
Expand All @@ -27,7 +27,7 @@ private function getUnknownRoomResponse(): JsonResponse
private function getToken(string $serverID, string $refreshToken): ?object
{
$entityManager = $this->getDoctrine()->getManager();
return $entityManager->getRepository(Tokens::class)->findOneBy([
return $entityManager->getRepository(Token::class)->findOneBy([
'serverid' => $serverID,
'refreshtoken' => $refreshToken
]);
Expand Down

0 comments on commit dba7088

Please sign in to comment.