public function onRegistrationSuccess(FormEvent $event)
 {
     $rolesArr = array('ROLE_AUTEUR');
     /** @var $user \FOS\UserBundle\Model\UserInterface */
     $user = $event->getForm()->getData();
     $user->setRoles($rolesArr);
 }
 public function onGroupEditSuccess(FormEvent $event)
 {
     if (null === $event->getResponse()) {
         $url = $this->router->generate($this->userDiscriminator->getCurrentUserConfig()->getRoutePrefix() . '_group_show', array('groupName' => $event->getForm()->getData()->getName()));
         $event->setResponse(new RedirectResponse($url));
     }
 }
 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));
 }
Ejemplo n.º 4
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)
 {
     $form = $event->getForm();
     $user = $form->getData();
     $plan = $form->get('plan')->getData();
     $this->subscription_manager->subscribe($user, $plan);
 }
 /**
  * @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);
 }
Ejemplo n.º 7
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);
 }
Ejemplo n.º 9
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 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);
 }
Ejemplo n.º 12
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));
 }
Ejemplo n.º 13
0
 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));
     }
 }
Ejemplo n.º 15
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));
 }
 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));
 }
 /**
  * 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(\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);
     }
 }
Ejemplo n.º 19
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);
 }
Ejemplo n.º 20
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));
 }
Ejemplo n.º 21
0
 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);
     }
 }
Ejemplo n.º 22
0
 public function onRegistrationSuccess(FormEvent $event)
 {
     $user = $event->getForm()->getData();
     if (null === $user->getConfirmationToken()) {
         $user->setConfirmationToken($this->tokenGenerator->generateToken());
         $user->setEmailExpiration(new \DateTime("+{$this->emailUnconfirmedTime}"));
     }
     $key = '_security.main.target_path';
     if ($this->session->has($key)) {
         //this is to be catch by loggedinUserListener.php
         return $event->setResponse(new RedirectResponse($this->router->generate('lc_home')));
     }
     $email = explode('@', $user->getEmailCanonical(), 2);
     $username = $email[0];
     if (!UsernameValidator::isUsernameValid($username)) {
         $url = $this->router->generate('lc_update_username');
     } else {
         $url = $this->router->generate('fos_user_profile_edit');
     }
     $event->setResponse(new RedirectResponse($url));
 }
Ejemplo n.º 23
0
 /**
  * Persist organization on staff registration success.
  *
  * @param \FOS\UserBundle\Event\FormEvent $event
  */
 public function onRegistrationSuccess(FormEvent $event)
 {
     /** @var $user \FOS\UserBundle\Model\UserInterface */
     $user = $event->getForm()->getData();
     $user->setAddDate(new \DateTime());
     $type = $user->getUserType();
     if ('staff' === $type) {
         $organization = $user->getOrganization();
         $organization->setTemp(true);
         $user->setOrganization($organization);
         $this->em->persist($organization);
         $user->addRole('ROLE_STAFF');
         $this->mailer->sendNewOrganization($organization);
     }
     if ('admin' === $type) {
         $user->addRole('ROLE_ADMIN');
     }
     if ('volunteer' === $type) {
         $user->setReceiveEmail(true);
         $user->setEnabled(true);
     }
 }
Ejemplo n.º 24
0
 public function onRegistrationSuccess(FormEvent $event)
 {
     $user = $event->getForm()->getData();
     if (null === $user->getConfirmationToken()) {
         $user->setConfirmationToken($this->tokenGenerator->generateToken());
         $user->setEmailExpiration(new \DateTime("+{$this->emailUnconfirmedTime}"));
     }
     if ($this->em->getRepository('PROCERGSLoginCidadaoCoreBundle:Person')->findOneBy(array('emailCanonical' => $user->getEmailCanonical()))) {
         throw new LcEmailException('registration.email.registered');
     }
     $key = '_security.main.target_path';
     if ($this->session->has($key)) {
         //this is to be catch by loggedinUserListener.php
         return $event->setResponse(new RedirectResponse($this->router->generate('lc_home')));
     }
     $email = explode('@', $user->getEmailCanonical(), 2);
     $username = $email[0];
     if (!UsernameValidator::isUsernameValid($username)) {
         $url = $this->router->generate('lc_update_username');
     } else {
         $url = $this->router->generate('fos_user_profile_edit');
     }
     $event->setResponse(new RedirectResponse($url));
 }
Ejemplo n.º 25
0
 public function onRegistrationSuccess(FormEvent $event)
 {
     $rolesArr = array('ROLE_PARTICULIER');
     $user = $event->getForm()->getData();
     $user->setRoles($rolesArr);
 }
Ejemplo n.º 26
0
 public function onProfileDocEditSuccess(FormEvent $event)
 {
     $user = $event->getForm()->getData();
     $this->checkCPFChanged($user);
 }
 public function onRegistrationSuccess(FormEvent $event)
 {
     $user = $event->getForm()->getData();
     $locale = $event->getRequest()->getLocale();
     $this->initProfile($user, $locale);
 }
 /**
  *
  * Sets the default role of the user
  *
  * @param FormEvent $formEvent
  */
 public function onRegistrationSuccess(FormEvent $formEvent)
 {
     $roles = ["ROLE_USER"];
     $user = $formEvent->getForm()->getData();
     $user->setRoles($roles);
 }
Ejemplo n.º 29
0
 function it_listens_registration_success(FormEvent $formEvent, FormInterface $form, Request $request, SessionInterface $session, UserInterface $user)
 {
     $formEvent->getForm()->shouldBeCalled()->willReturn($form);
     $form->getData()->shouldBeCalled()->willReturn($user);
     $formEvent->getRequest()->shouldBeCalled()->willReturn($request);
     $request->getSession()->shouldBeCalled()->willReturn($session);
     $user->getEmail()->shouldBeCalled()->willReturn('*****@*****.**');
     $user->getPlainPassword()->shouldBeCalled()->willReturn('123456');
     $session->set('_email', '*****@*****.**')->shouldBeCalled();
     $session->set('_password', '123456')->shouldBeCalled();
     $this->onRegistrationSuccess($formEvent);
 }
 public function setPasswordEncoderName(FormEvent $event)
 {
     $person = $event->getForm()->getData();
     $person->setPasswordEncoderName($this->defaultPasswordEncoder);
     $this->session->remove('force_password_change');
 }