]> Raphaƫl G. Git Repositories - userbundle/blobdiff - Repository/UserRepository.php
Enable register captcha
[userbundle] / Repository / UserRepository.php
index d75e229959d12b4ccacb903f73d8c574839ba40e..077b50073e3d78d8b32f087c803969e088dfd1c4 100644 (file)
 namespace Rapsys\UserBundle\Repository;
 
 use Doctrine\ORM\Query\ResultSetMapping;
 namespace Rapsys\UserBundle\Repository;
 
 use Doctrine\ORM\Query\ResultSetMapping;
+
+use Rapsys\UserBundle\Repository;
+
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
+use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
 
 /**
  * UserRepository
  */
 
 /**
  * UserRepository
  */
-class UserRepository extends EntityRepository {
+class UserRepository extends Repository implements PasswordUpgraderInterface {
        /**
         * Find user count as int
         *
        /**
         * Find user count as int
         *
@@ -119,7 +124,7 @@ SQL;
                                'pseudonym' => $data['pseudonym'],
                                'groups' => [],
                                'slug' => $this->slugger->slug($data['pseudonym']),
                                'pseudonym' => $data['pseudonym'],
                                'groups' => [],
                                'slug' => $this->slugger->slug($data['pseudonym']),
-                               'link' => $this->router->generate('rapsys_user_edit', ['mail' => $short = $this->slugger->short($data['mail']), 'hash' => $this->slugger->hash($short)])
+                               'link' => $this->router->generate('rapsysuser_edit', ['mail' => $short = $this->slugger->short($data['mail']), 'hash' => $this->slugger->hash($short)])
                        ];
 
                        //With groups
                        ];
 
                        //With groups
@@ -133,7 +138,7 @@ SQL;
                                        $ret[$data['id']]['groups'][$id] = [
                                                'title' => $group = $this->translator->trans($titles[$k]),
                                                #'slug' => $this->slugger->slug($group)
                                        $ret[$data['id']]['groups'][$id] = [
                                                'title' => $group = $this->translator->trans($titles[$k]),
                                                #'slug' => $this->slugger->slug($group)
-                                               #'link' => $this->router->generate('rapsys_user_group_view', ['id' => $id, 'slug' => $this->slugger->short($group)])
+                                               #'link' => $this->router->generate('rapsysuser_group_view', ['id' => $id, 'slug' => $this->slugger->short($group)])
                                        ];
                                }
                        }
                                        ];
                                }
                        }
@@ -142,4 +147,15 @@ SQL;
                //Send result
                return $ret;
        }
                //Send result
                return $ret;
        }
+
+       /**
+        * {@inheritdoc}
+        */
+       public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $hash): void {
+               //Set new hashed password
+               $user->setPassword($hash);
+
+               //Flush data to database
+               $this->getEntityManager()->flush();
+       }
 }
 }