Open LambertHumans opened 2 years ago
Hello
I have exactly the same problem.
I tried following these instructions: https://github.com/markitosgv/JWTRefreshTokenBundle/issues/332
But the result is the same.
I'm on SF 6 and PHP 8
In the documentation we have to update our database with the new RefreshToken entity and absolutely nothing happens even when forcing the update.
@LambertHumans after looking a second time the Following procedure : https://github.com/markitosgv/JWTRefreshTokenBundle/issues/332
I have change the entity and It works now
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken as BaseRefreshToken;
#[ORM\Entity]
#[ORM\Table(name: 'refresh_token')]
class RefreshToken extends BaseRefreshToken
{
public function getId()
{
return $this->id;
}
}
@Lugh-Web, thanks for dropping this in! This also fixed my issue.
I've been struggling for a while to set up this refresh token using SF 6.2 + API platform 3.1 using PHP8.2
It looks like there are conflicts between annotations and attributes, and that the RefreshTokenRepository cannot be reached inside the vendor directory.
I searched on the web for similar issues, found several in 2022 but nothing really recent.
Anyway I finally made it work by modifying the RefreshToken.php and placing the RefreshTokenRepository inside the project Repository folder. These are the only differences I implemented vs this documentation.
Here is the adjusted Entity
namespace App\Entity\Main;
use Doctrine\ORM\Mapping as ORM;
use Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken as BaseRefreshToken;
#[ORM\Table(name: 'refresh_token')]
#[ORM\Entity(repositoryClass: 'App\Repository\Main\RefreshTokenRepository')]
class RefreshToken extends BaseRefreshToken
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
protected $id;
#[ORM\Column(type: 'string')]
protected $refreshToken;
#[ORM\Column(type: 'string')]
protected $username;
#[ORM\Column(type: 'datetime')]
protected $valid;
}
And the Repository simply copied from the vendor dir and pasted in the project
namespace App\Repository\Main;
use Doctrine\ORM\EntityRepository;
use Gesdinet\JWTRefreshTokenBundle\Doctrine\RefreshTokenRepositoryInterface;
/**
* @extends EntityRepository<RefreshToken>
* @implements RefreshTokenRepositoryInterface<RefreshToken>
*/
class RefreshTokenRepository extends EntityRepository implements RefreshTokenRepositoryInterface
{
/**
* @param \DateTimeInterface|null $datetime
*
* @return RefreshToken[]
*/
public function findInvalid($datetime = null)
{
$datetime = (null === $datetime) ? new \DateTime() : $datetime;
return $this->createQueryBuilder('u')
->where('u.valid < :datetime')
->setParameter(':datetime', $datetime)
->getQuery()
->getResult();
}
}
Hope this will help others
Hi everyone, I just installed Gesdinet JWT refresh token, but can't make it works. I'm facing this error :
Class "App\Entity\RefreshToken" sub class of "Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken" is not a valid entity or mapped super class.
I didn't made any change on bundle configuration, I only replaced refresh token route. I'm using Sf6 with postgresql and php8.1.
Do you guys have an idea on how I can solve this ?
Thank you !