예제 #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;
 }
예제 #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());
 }
예제 #3
0
 public function testCountInactiveUsers()
 {
     $this->assertEquals(1, $this->manager->countInactiveUsers());
 }