UserMapper.php 938 Bytes
Newer Older
1 2 3 4
<?php

namespace UnicaenAuth\Service;

5
use UnicaenAuth\Entity\Db\AbstractUser;
6 7 8 9
use ZfcUserDoctrineORM\Mapper\User as ZfcUserDoctrineORMUserMapper;

class UserMapper extends ZfcUserDoctrineORMUserMapper
{
10 11 12 13 14 15 16 17 18 19 20 21 22 23
    /**
     * Recherche un utilisateur par son username (identifiant de connexion).
     *
     * @param string $username
     * @return AbstractUser|null
     */
    public function findOneByUsername($username)
    {
        /** @var AbstractUser $user */
        $user = $this->em->getRepository($this->options->getUserEntityClass())->findOneBy(['username' => $username]);

        return $user;
    }

24 25
    /**
     * @param string $token
26
     * @return AbstractUser
27 28 29
     */
    public function findOneByPasswordResetToken($token)
    {
30
        /** @var AbstractUser $user */
31 32 33 34 35
        $user = $this->em->getRepository($this->options->getUserEntityClass())->findOneBy(['passwordResetToken' => $token]);

        return $user;
    }
}