function its_on_registration_success(FormEvent $event, UrlGeneratorInterface $router, RandomUsernameGenerator $generator)
 {
     $router->generate('quickstart_app_account')->shouldBeCalled()->willReturn('/en/account');
     $this->beConstructedWith($router, $generator);
     $event->setResponse(Argument::type('Symfony\\Component\\HttpFoundation\\RedirectResponse'))->shouldBeCalled();
     $this->onRegistrationSuccess($event);
 }
 /**
  * @param InteractiveLoginEvent $event
  */
 public function onRegistration(FormEvent $event)
 {
     $user = $event->getForm()->getData();
     $language = $this->entityManager->getRepository('MagicWordBundle:Language')->findOneByName('french');
     $user->setLanguage($language);
     $this->wordboxManager->createWordbox($user);
 }
 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 onProfileEditSuccess(FormEvent $event)
 {
     if ($event->getRequest()->isXmlHttpRequest()) {
         $response = new RedirectResponse($this->router->generate('fos_user_profile_edit'));
         $event->setResponse($response);
     }
 }
Пример #5
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()));
 }
 public function onChangePasswordSuccess(FormEvent $event)
 {
     $person = $event->getForm()->getData();
     $this->notificationHelper->clearEmptyPasswordNotification($person);
     $url = $this->router->generate('fos_user_change_password');
     $event->setResponse(new RedirectResponse($url));
 }
 public function onRegistrationSuccess(FormEvent $event)
 {
     $rolesArr = array('ROLE_AUTEUR');
     /** @var $user \FOS\UserBundle\Model\UserInterface */
     $user = $event->getForm()->getData();
     $user->setRoles($rolesArr);
 }
Пример #8
0
 public function onRegistrationSuccess(FormEvent $event)
 {
     /** @var User $user */
     $user = $event->getForm()->getData();
     $apiToken = substr($this->tokenGenerator->generateToken(), 0, 20);
     $user->setApiToken($apiToken);
 }
 public function onRegistrationSuccess(FormEvent $event)
 {
     if (null === $event->getResponse()) {
         $url = $this->router->generate($this->userDiscriminator->getCurrentUserConfig()->getRoutePrefix() . '_registration_confirmed');
         $event->setResponse(new RedirectResponse($url));
     }
 }
 public function onRegistrationSuccess(FormEvent $event)
 {
     $form = $event->getForm();
     $user = $form->getData();
     $plan = $form->get('plan')->getData();
     $this->subscription_manager->subscribe($user, $plan);
 }
 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 ($event->getRequest()->isXmlHttpRequest()) {
         $response = new RedirectResponse($this->router->generate('fos_user_change_password'));
         $event->setResponse($response);
     }
 }
Пример #13
0
 public function onUserCreated(\FOS\UserBundle\Event\FormEvent $event)
 {
     $form = $event->getForm();
     $user = $form->getData();
     $request = $event->getRequest();
     $admin = $this->container->get('sf.admin.loader')->getAdminByClass(get_class($user));
     $admin->setUserRegistration($user, $request);
 }
 public function onRegistrationSuccess(FormEvent $event)
 {
     $form = $event->getForm();
     /** @var User $user */
     $user = $form->getData();
     $userType = $form->get('type')->getData();
     $user->addRole($userType);
 }
 public function onFormSuccess(FormEvent $event)
 {
     $url = $this->router->generate('syw_front_main_main_index');
     if ($event == FOSUserEvents::REGISTRATION_SUCCESS) {
         $this->get('session')->getFlashBag()->add('success', 'Your registration was successful. An email was sent to your postbox. Please check it and click the confirmation link.');
     }
     $event->setResponse(new RedirectResponse($url));
 }
Пример #16
0
 public function onResettingResetSuccess(FormEvent $event)
 {
     /** @var $user \FOS\UserBundle\Model\UserInterface */
     $user = $event->getForm()->getData();
     $user->setConfirmationToken(null);
     $user->setPasswordRequestedAt(null);
     $user->setEnabled(true);
 }
 public function onPasswordResettingSuccess(FormEvent $event)
 {
     $user = $this->context->getToken()->getUser();
     $user->setIsSiteRegistered(true);
     $this->user_manager->updateUser($user);
     $url = $this->router->generate('homepage');
     $event->setResponse(new RedirectResponse($url));
 }
 public function onRegistrationSuccess(FormEvent $event)
 {
     $user = $event->getForm()->getData();
     $user->setCreatedIp($event->getRequest()->getClientIp());
     $user->setCreatedTime(time());
     //note: 如果 $event->getResponse() 有值,将不会跳转到注册成功页面,而继续执行 FOSUserEvents::REGISTRATION_COMPLETED
     //note: 注册成功
 }
 public function onRegisteringUserSuccess(FormEvent $event)
 {
     if ($event->getRequest()->attributes->get('_locale')) {
         $userLanguage = $event->getRequest()->attributes->get('_locale');
     } else {
         // if no explicit locale has been set on this request, use the preferred language the user chose for his browser
         $userLanguage = $event->getRequest()->getPreferredLanguage();
     }
     $event->getForm()->getData()->setLanguage($userLanguage);
 }
Пример #20
0
 public function onResettingResetSuccess(FormEvent $event)
 {
     /** @var $user \FOS\UserBundle\Model\UserInterface */
     $user = $event->getForm()->getData();
     $user->setConfirmationToken(null);
     $user->setPasswordRequestedAt(null);
     $user->setEnabled(true);
     $url = $this->router->generate('fos_user_profile_edit');
     $event->setResponse(new RedirectResponse($url));
 }
 public function onResettingResetSuccess(FormEvent $event)
 {
     $user = $event->getForm()->getData();
     if ($user instanceof User) {
         $audit = AuditLog::make($user, 'password-reset', $event->getRequest()->getClientIp());
         $this->em->persist($audit);
         $plog = PasswordLog::make($user, $event->getRequest()->getClientIp());
         $this->em->persist($plog);
         $this->em->flush();
     }
 }
 public function onProfileEditSuccess(FormEvent $event)
 {
     $user = $event->getForm()->getData();
     if ($user->getEmail() !== $this->email) {
         $user->setConfirmationToken($this->tokenGenerator->generateToken());
         $this->mailer->sendEmailMessage($user);
         $this->security->setToken();
         $user->setEmail($this->email);
         $this->session->set('fos_user_send_confirmation_email/email', $user->getEmail());
         $url = $this->router->generate('fos_user_registration_check_email');
         $event->setResponse(new RedirectResponse($url));
     }
 }
Пример #23
0
 public function onRegistrationSuccess(FormEvent $event)
 {
     /** @var $user \FOS\UserBundle\Model\UserInterface */
     $user = $event->getForm()->getData();
     $user->setEnabled(false);
     if (null === $user->getConfirmationToken()) {
         $user->setConfirmationToken($this->tokenGenerator->generateToken());
     }
     $this->mailer->sendConfirmationEmailMessage($user);
     $this->session->set('fos_user_send_confirmation_email/email', $user->getEmail());
     $url = $this->router->generate('fos_user_registration_check_email');
     $event->setResponse(new RedirectResponse($url));
 }
Пример #24
0
 public function onChangePasswordSuccess(FormEvent $event)
 {
     $user = $this->token_storage->getToken()->getUser();
     if (!is_null($this->password_expire_time)) {
         $currentDate = new \DateTime();
         $currentDate->add(new \DateInterval($this->password_expire_time));
         $user->setPasswordExpireAt($currentDate);
     } else {
         $user->setPasswordExpireAt();
     }
     $this->usermanager->updateUser($user);
     $url = $this->router->generate('homepage');
     $event->setResponse(new RedirectResponse($url));
 }
 /**
  * Used only to get form reference because it's not available in the next event, onRegistrationCompleted
  * @param FormEvent $event
  */
 public function onRegistrationSuccess(FormEvent $event)
 {
     /**
      * Disclaimer: Subscriber does all it's magic in onRegistrationCompleted method,
      * however in onRegistrationCompleted we don't have access form (so we can get tenant name and subdomain)
      * and http response (so we can redirect user to his new tenant instance)
      *
      * That's why we are using other event that is fired before onRegistrationCompleted and we grab references to
      * form and response objects that will be used in that next event.
      */
     $this->_form = $event->getForm();
     // we get reference to the redirect response that will be used in another event
     $this->redirectResponse = new RedirectResponse('dummy');
     // FOS User Registration controller check if response is set in event, if so it will just use it.
     $event->setResponse($this->redirectResponse);
 }
 public function onRegistrationSuccess(FormEvent $event)
 {
     if (!$this->userDiscriminator->getCurrentUserConfig()->getConfig('registering.confirmation.enabled', false)) {
         return;
     }
     /** @var $user \FOS\UserBundle\Model\UserInterface */
     $user = $event->getForm()->getData();
     $user->setEnabled(false);
     if (null === $user->getConfirmationToken()) {
         $user->setConfirmationToken($this->tokenGenerator->generateToken());
     }
     $this->mailer->sendConfirmationEmailMessage($user);
     $this->session->set('fos_user_send_confirmation_email/email', $user->getEmail());
     $url = $this->router->generate($this->userDiscriminator->getCurrentUserConfig()->getRoutePrefix() . '_registration_check_email');
     $event->setResponse(new RedirectResponse($url));
 }
 public function onRegistrationSuccess(\FOS\UserBundle\Event\FormEvent $event)
 {
     if ($event->getRequest()->isXmlHttpRequest()) {
         /** @var $user \FOS\UserBundle\Model\UserInterface */
         $user = $event->getForm()->getData();
         $user->setEnabled(false);
         if (null === $user->getConfirmationToken()) {
             $user->setConfirmationToken($this->tokenGenerator->generateToken());
         }
         $this->mailer->sendConfirmationEmailMessage($user);
         $data = array('message' => $this->translator->trans('registration.check_email', array('%email%' => $user->getEmail()), 'FOSUserBundle'));
         $event->setResponse(new \Symfony\Component\HttpFoundation\JsonResponse($data));
     } else {
         return parent::onRegistrationSuccess($event);
     }
 }
Пример #28
0
 public function onPasswordChange(FormEvent $event)
 {
     // Get new password
     /** @var User $user */
     $user = $event->getForm()->getData();
     $password = $user->getPlainPassword();
     // Get pkey from session
     $privKey = $event->getRequest()->getSession()->get('pkey');
     // Secure pkey with new password
     $res = openssl_pkey_get_private($privKey);
     openssl_pkey_export($res, $privKey, $password);
     // Store pkey in user
     $user->setPrivateKey($privKey);
     unset($password);
     openssl_pkey_free($res);
     unset($privKey);
 }
Пример #29
0
 public function onCreationSuccess(FormEvent $event)
 {
     /** @var $user Tkuska\UserBundle\Entity\User */
     $user = $event->getForm()->getData();
     $user->setPlainPassword(substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, 10));
     $user->setEnabled(false);
     if ($this->forceChangePassword) {
         $user->setPasswordExpireAt(new \DateTime());
     }
     if (null === $user->getConfirmationToken()) {
         $user->setConfirmationToken($this->tokenGenerator->generateToken());
     }
     $this->mailer->sendCreationEmailMessage($user);
     $this->session->set('fos_user_send_confirmation_email/email', $user->getEmail());
     $url = $this->router->generate('tkuska_user_creation_create');
     $event->setResponse(new RedirectResponse($url));
 }
 public function onRegistrationSuccess(FormEvent $event)
 {
     if ($event->getRequest()->isXmlHttpRequest()) {
         /** @var $user \FOS\UserBundle\Model\UserInterface */
         $user = $event->getForm()->getData();
         $user->setEnabled(false);
         if (null === $user->getConfirmationToken()) {
             $user->setConfirmationToken($this->tokenGenerator->generateToken());
         }
         $this->mailer->sendConfirmationEmailMessage($user);
         $this->session->set('fos_user_send_confirmation_email/email', $user->getEmail());
         $data = array('success' => true);
         $event->setResponse(new \Symfony\Component\HttpFoundation\JsonResponse($data));
     } else {
         return parent::onRegistrationSuccess($event);
     }
 }