You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems the trait ResetPasswordRequestRepositoryTrait does not support UUID and ULID because with Doctrine, it must add 'ulid' as the third argument to tell Doctrine that this is a ULID or alternatively, you can convert it to a value compatible with the type inferred by Doctrine (see https://symfony.com/doc/current/components/uid.html#storing-ulids-in-databases).
I have to override 2 trait methods to do them work:
class ResetPasswordRequestRepository extends ServiceEntityRepository implements ResetPasswordRequestRepositoryInterface
{
use ResetPasswordRequestRepositoryTrait;
publicfunction__construct(ManagerRegistry$registry)
{
parent::__construct($registry, ResetPasswordRequest::class);
}
/** * @param User $user */publicfunctioncreateResetPasswordRequest(
object$user,
DateTimeInterface$expiresAt,
string$selector,
string$hashedToken
): ResetPasswordRequestInterface {
returnnewResetPasswordRequest($user, $expiresAt, $selector, $hashedToken);
}
/** * Override trait method because of using ulid for user ID. * * @param User $user */publicfunctiongetMostRecentNonExpiredRequestDate(object$user): ?DateTimeInterface
{
// Normally there is only 1 max request per use, but written to be flexible/** @var ResetPasswordRequestInterface $resetPasswordRequest */$resetPasswordRequest = $this->createQueryBuilder('t')
->where('t.user = :user')
->setParameter('user', $user->getId(), 'ulid')
->orderBy('t.requestedAt', 'DESC')
->setMaxResults(1)
->getQuery()
->getOneorNullResult()
;
if (null !== $resetPasswordRequest && !$resetPasswordRequest->isExpired()) {
return$resetPasswordRequest->getRequestedAt();
}
returnnull;
}
/** * Override trait method because of using ulid for user ID. */publicfunctionremoveResetPasswordRequest(ResetPasswordRequestInterface$resetPasswordRequest): void
{
/** @var User $user */$user = $resetPasswordRequest->getUser();
$this->createQueryBuilder('t')
->delete()
->where('t.user = :user')
->setParameter('user', $user->getId(), 'ulid')
->getQuery()
->execute()
;
}
}
Did I have another solution?
Thanks a lot,
Mickaël
The text was updated successfully, but these errors were encountered:
I'm facing this issue too. Adding the error I'm facing here, it might help others finding this thread:
An exception occurred while executing a query: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type uuid: "01G56C##############"
In the meantime, thanks @misaert for your workaround 👍
Tangentially related: The trait needs to check how many rows were affected, otherwise this just fails silently and the link is reusable until it's cleaned up!
Hi,
It seems the trait
ResetPasswordRequestRepositoryTrait
does not support UUID and ULID because with Doctrine, it must add 'ulid' as the third argument to tell Doctrine that this is a ULID or alternatively, you can convert it to a value compatible with the type inferred by Doctrine (see https://symfony.com/doc/current/components/uid.html#storing-ulids-in-databases).I have to override 2 trait methods to do them work:
Did I have another solution?
Thanks a lot,
Mickaël
The text was updated successfully, but these errors were encountered: