public function onGroupDeleteCompleted(FormEvent $event)
 {
     if ($event->getResponse() instanceof RedirectResponse) {
         $url = $this->router->generate($this->userDiscriminator->getCurrentUserConfig()->getRoutePrefix() . '_group_list');
         $event->setResponse(new RedirectResponse($url));
     }
 }
 public function onChangePasswordSuccess(FormEvent $event)
 {
     if (null === $event->getResponse()) {
         $url = $this->router->generate($this->userDiscriminator->getCurrentUserConfig()->getRoutePrefix() . '_profile_show');
         $event->setResponse(new RedirectResponse($url));
     }
 }
 public function onRegistrationSuccess(FormEvent $event)
 {
     if (null === $event->getResponse()) {
         $url = $this->router->generate($this->userDiscriminator->getCurrentUserConfig()->getRoutePrefix() . '_registration_confirmed');
         $event->setResponse(new RedirectResponse($url));
     }
 }
예제 #4
0
 public function registerAction(Request $request)
 {
     /** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */
     $formFactory = $this->get('fos_user.registration.form.factory');
     /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
     $userManager = $this->get('fos_user.user_manager');
     /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
     $dispatcher = $this->get('event_dispatcher');
     $user = $userManager->createUser();
     $user->setEnabled(true);
     $event = new GetResponseUserEvent($user, $request);
     //$dispatcher->dispatch(FOSUserEvents::REGISTRATION_INITIALIZE, $event);
     if (null !== $event->getResponse()) {
         return $event->getResponse();
     }
     $form = $formFactory->createForm();
     $form->setData($user);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $event = new FormEvent($form, $request);
         //$dispatcher->dispatch(FOSUserEvents::REGISTRATION_SUCCESS, $event);
         $userManager->updateUser($user);
         if (null === ($response = $event->getResponse())) {
             $url = $this->generateUrl('msi_user_admin_add_user');
             $response = new RedirectResponse($url);
         }
         $session = $request->getSession();
         $session->getFlashBag()->add('info_user_add', $this->get('translator')->trans('msi.core.admin.add.user.info', array('%username%' => $user->getUsername()), 'Admin'));
         //$dispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
         return $response;
     }
     return $this->render('MSIUserBundle:Registration:register.html.twig', array('form' => $form->createView()));
 }
예제 #5
0
 /**
  * Change user password
  */
 public function confirmResetPasswordAction(Request $request)
 {
     $token = $request->get('token');
     /** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */
     $formFactory = $this->get('fos_user.resetting.form.factory');
     /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
     $userManager = $this->get('fos_user.user_manager');
     /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
     $dispatcher = $this->get('event_dispatcher');
     $user = $userManager->findUserByConfirmationToken($token);
     if (null === $user) {
         throw new NotFoundHttpException(sprintf('The user with "confirmation token" does not exist for value "%s"', $token));
     }
     $event = new GetResponseUserEvent($user, $request);
     if (null !== $event->getResponse()) {
         return $event->getResponse();
     }
     $form = $formFactory->createForm();
     $form->setData($user);
     $form->handleRequest($request);
     $error = '';
     if ($request->getMethod() == 'POST') {
         if ($form->isValid()) {
             $event = new FormEvent($form, $request);
             $user->setConfirmationToken(null);
             $user->setPasswordRequestedAt(null);
             $userManager->updateUser($user);
             if (null === ($response = $event->getResponse())) {
                 $url = $this->generateUrl('enhavo_dashboard_index');
                 $response = new RedirectResponse($url);
                 $this->authenticateUser($user, $response);
                 return $response;
             }
         } else {
             foreach ($form->getErrors() as $errorMessage) {
                 $error = $errorMessage;
             }
         }
     }
     return $this->render('EnhavoUserBundle:Security:reset-password-confirm.html.twig', array('token' => $token, 'error' => $error, 'form' => $form->createView()));
 }
 /**
  * Function used to support registration process
  * @param Request $request Request object
  *
  * @return RedirectResponse
  */
 public function userRegistration(Request $request)
 {
     /** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */
     $formFactory = $this->container->get('fos_user.registration.form.factory');
     /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
     $userManager = $this->container->get('fos_user.user_manager');
     /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
     $dispatcher = $this->container->get('event_dispatcher');
     $user = $userManager->createUser();
     $user->setEnabled(true);
     $user->setIsResigned(0);
     // Setting admin flag to 0
     $user->setJoiningDate(new \DateTime("now"));
     $em = $this->container->get('doctrine')->getManager();
     $group = $em->getRepository('SkyrocketLoginBundle:EmployeeGroup')->getEmployeeGroupId();
     $group = $em->getRepository('SkyrocketLoginBundle:EmployeeGroup')->find($group);
     $user->addGroup($group);
     $event = new GetResponseUserEvent($user, $request);
     $dispatcher->dispatch(FOSUserEvents::REGISTRATION_INITIALIZE, $event);
     if (null !== $event->getResponse()) {
         return $event->getResponse();
     }
     $form = $formFactory->createForm();
     $form->setData($user);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $event = new FormEvent($form, $request);
         $userManager->updateUser($user);
         if (null === ($response = $event->getResponse())) {
             $url = $this->container->get('router')->generate('skyrocket_admin_homepage');
             $response = new RedirectResponse($url);
         }
         return $response;
     }
     return $this->container->get('templating')->renderResponse('SkyrocketLoginBundle:Registration:register.html.twig', array('form' => $form->createView()));
 }
 /**
  * @Security("has_role('ROLE_USER_INVITER')")
  * @Route("/invite", name="fos_user_registration_register")
  */
 public function inviteAction(Request $request)
 {
     $currentUser = $this->container->get('security.token_storage')->getToken()->getUser();
     /** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */
     $formFactory = $this->get('fos_user.registration.form.factory');
     /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
     $userManager = $this->get('fos_user.user_manager');
     /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
     $dispatcher = $this->get('event_dispatcher');
     $user = $userManager->createUser();
     $user->setEnabled(true);
     $event = new GetResponseUserEvent($user, $request);
     $dispatcher->dispatch(FOSUserEvents::REGISTRATION_INITIALIZE, $event);
     if (null !== $event->getResponse()) {
         return $event->getResponse();
     }
     $form = $formFactory->createForm();
     $form->setData($user);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $event = new FormEvent($form, $request);
         $tokenGenerator = $this->container->get('fos_user.util.token_generator');
         $user->setConfirmationToken($tokenGenerator->generateToken());
         $user->setUsername($user->getEmail());
         $user->setEnabled(false);
         $user->setInviter($currentUser);
         $userManager->updateUser($user);
         $userid = $user->getId();
         if (null === ($response = $event->getResponse())) {
             //$url = $this->generateUrl('fos_user_registration_confirmed');
             $url = $this->generateUrl('userBundle_approve', array('id' => $userid));
             $response = new RedirectResponse($url);
         }
         //$dispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
         return $response;
     }
     return $this->render('FOSUserBundle:Registration:register.html.twig', array('form' => $form->createView()));
 }