Example #1
0
 /**
  * @param string $username
  * @throws \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
  * @return \Symfony\Component\Security\Core\User\UserInterface
  */
 public function loadUserByUsername($username) : UserInterface
 {
     if (($user = $this->manager->findUserByUsernameOrEmail($username)) === null) {
         throw new UsernameNotFoundException("Username \"{$username}\" does not exist.");
     }
     return $user;
 }
Example #2
0
 /**
  * @Route("/register", name="user_register")
  * @Template()
  */
 public function registerAction()
 {
     $user = new User();
     $form = $this->createForm($this->userType, $user);
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bind($this->getRequest());
         if ($form->isValid()) {
             $this->userManager->register($user);
             $redirectUrl = $this->getRequest()->getSession()->get('_security.app.target_path');
             if (!$redirectUrl) {
                 $redirectUrl = $this->generateUrl('post_list');
             }
             return $this->redirect($redirectUrl);
         }
     }
     return array('form' => $form->createView());
 }
 public function testCountInactiveUsers()
 {
     $this->assertEquals(1, $this->manager->countInactiveUsers());
 }