|
@@ -6,8 +6,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|
|
use Doctrine\Common\Collections\Criteria;
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
|
|
-use Symfony\Component\Security\Core\User\UserInterface;
|
|
|
-use Symfony\Component\Security\Core\User\UserProviderInterface;
|
|
|
|
|
|
|
|
|
* User
|
|
@@ -15,7 +13,7 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
|
|
|
* @ORM\Table(name="user")
|
|
|
* @ORM\Entity(repositoryClass="Entity\Repository\UserRepository")
|
|
|
*/
|
|
|
-class User implements AdvancedUserInterface, UserProviderInterface
|
|
|
+class User implements AdvancedUserInterface
|
|
|
{
|
|
|
|
|
|
* @var integer
|
|
@@ -238,8 +236,6 @@ class User implements AdvancedUserInterface, UserProviderInterface
|
|
|
*/
|
|
|
private $salt;
|
|
|
|
|
|
- private $em;
|
|
|
-
|
|
|
|
|
|
*
|
|
|
*/
|
|
@@ -253,83 +249,35 @@ class User implements AdvancedUserInterface, UserProviderInterface
|
|
|
}
|
|
|
|
|
|
|
|
|
- * Needed in order to use the security component
|
|
|
- * @param \Doctrine\ORM\EntityManager $em
|
|
|
- */
|
|
|
- public function setEntityManager($em)
|
|
|
- {
|
|
|
- $this->em = $em;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * @param string $username
|
|
|
- * @return mixed
|
|
|
- * @throws UsernameNotFoundException
|
|
|
- */
|
|
|
- public function loadUserByUsername($username)
|
|
|
- {
|
|
|
- $q = $this->em
|
|
|
- ->createQueryBuilder('u')
|
|
|
- ->select('u')
|
|
|
- ->from('Entity\User', 'u')
|
|
|
- ->where('u.username = :username OR u.email = :email')
|
|
|
- ->setParameter('username', $username)
|
|
|
- ->setParameter('email', $username)
|
|
|
- ->getQuery();
|
|
|
-
|
|
|
- try {
|
|
|
- $user = $q->getSingleResult();
|
|
|
-
|
|
|
- } catch (NoResultException $e) {
|
|
|
- throw new UsernameNotFoundException(
|
|
|
- sprintf('Unable to find an active admin User identified by "%s".', $username),
|
|
|
- null,
|
|
|
- 0,
|
|
|
- $e
|
|
|
- );
|
|
|
- }
|
|
|
- return $user;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * @param UserInterface $user
|
|
|
- * @return mixed
|
|
|
- * @throws UnsupportedUserException
|
|
|
+ * @inheritDoc
|
|
|
*/
|
|
|
- public function refreshUser(UserInterface $user)
|
|
|
+ public function isAccountNonExpired()
|
|
|
{
|
|
|
- $class = get_class($user);
|
|
|
- if (!$this->supportsClass($class)) {
|
|
|
- throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $class));
|
|
|
- }
|
|
|
-
|
|
|
- return $this->loadUserByUsername($user->getUsername());
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
- * @param string $class
|
|
|
- * @return bool
|
|
|
+ * @inheritDoc
|
|
|
*/
|
|
|
- public function supportsClass($class)
|
|
|
+ public function isAccountNonLocked()
|
|
|
{
|
|
|
- return $this->getEntityName() === $class || is_subclass_of($class, $this->getEntityName());
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
* @inheritDoc
|
|
|
*/
|
|
|
- public function getRoles()
|
|
|
+ public function isCredentialsNonExpired()
|
|
|
{
|
|
|
- return $this->roles->toArray();
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
- *
|
|
|
- * @return ArrayCollection
|
|
|
+ * @inheritDoc
|
|
|
*/
|
|
|
- public function getRolesObj()
|
|
|
+ public function isEnabled()
|
|
|
{
|
|
|
- return $this->roles;
|
|
|
+ return $this->getActive() == 1;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -339,37 +287,25 @@ class User implements AdvancedUserInterface, UserProviderInterface
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- * @inheritDoc
|
|
|
- */
|
|
|
- public function isAccountNonExpired()
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
|
|
|
|
|
|
* @inheritDoc
|
|
|
*/
|
|
|
- public function isAccountNonLocked()
|
|
|
+ public function getRoles()
|
|
|
{
|
|
|
- return true;
|
|
|
+ return $this->roles->toArray();
|
|
|
}
|
|
|
|
|
|
|
|
|
- * @inheritDoc
|
|
|
+ *
|
|
|
+ * @return ArrayCollection
|
|
|
*/
|
|
|
- public function isCredentialsNonExpired()
|
|
|
+ public function getRolesObj()
|
|
|
{
|
|
|
- return true;
|
|
|
+ return $this->roles;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- * @inheritDoc
|
|
|
- */
|
|
|
- public function isEnabled()
|
|
|
- {
|
|
|
- return $this->getActive() == 1;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
* Set salt
|