Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function sendResettingEmailMessage(UserEntity $user)
 {
     $template = $this->parameters['resetting.template'];
     $url = $this->router->generate('resetting_reset', array('token' => $user->getConfirmationToken()), UrlGeneratorInterface::ABSOLUTE_URL);
     $rendered = $this->templating->render($template, array('user' => $user, 'confirmationUrl' => $url));
     $this->sendEmailMessage($rendered, $user->getEmail());
 }
Ejemplo n.º 2
0
 public function registerAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
     $dispatcher = $this->get('event_dispatcher');
     $user = new UsuarioEntity();
     $user->setLastModified(new \DateTime());
     if ($request->getMethod() == 'GET') {
         //Usar getClientIp.
         $content = @file_get_contents('http://www.geoplugin.net/php.gp?ip=212.128.152.1');
         if (isset($http_response_header) && strpos($http_response_header[0], '200')) {
             $meta = unserialize($content);
             //Obtenemos el pais.
             $defaultCountry = $em->getRepository('juzzUsuariosBundle:Paises')->findOneBy(array('iso' => $meta['geoplugin_countryCode']));
             //Establecemos origen por defecto.
             $user->setOrigen($defaultCountry);
         }
     }
     $form = $this->createForm(new UsuarioRegistroType(), $user);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $event = new RegistrationEvent($form, $user);
         $dispatcher->dispatch(UsuariosBundleEvents::REGISTRATION_SUCCESS, $event);
         //Necesitamos saber el algoritmo de codificación utilizado en la contraseña.
         //Para poderlo aplicar a nuestros usuarios.
         $encoder = $this->get('security.encoder_factory')->getEncoder($user);
         $password = $encoder->encodePassword($user->getPlainPassword(), $user->getSalt());
         $user->setPassword($password);
         $user->setIngreso(new \DateTime());
         //Establecemos politica de comentarios por defecto.
         $policy = $em->getRepository('juzzCommentsBundle:PoliticaComentarios')->find(1);
         $user->setPoliticaComentarios($policy);
         if (null === ($response = $event->getResponse())) {
             $user->setActivo(1);
             $translated = $this->get('translator')->trans('registration.flash.user_created', array('%username%' => $user->getFullName()), 'juzzUsuariosBundle');
             // Crear un mensaje flash para notificar al usuario que se ha registrado correctamente
             $this->get('ras_flash_alert.alert_reporter')->addSuccess($translated);
             //Notificamos que la cuenta ha sido activada.
             $event = new RegistrationConfirmedEvent($user);
             $dispatcher->dispatch(UsuariosBundleEvents::REGISTRATION_CONFIRM, $event);
             if (null === ($response = $event->getResponse())) {
                 $response = $this->redirect($this->generateUrl('confirmed'));
             }
         }
         // Guardar el nuevo usuario en la base de datos
         $em->persist($user);
         $em->flush();
         return $response;
     }
     return $this->render('juzzUsuariosBundle:Accounts:registration/register.html.twig', array('form' => $form->createView()));
 }
Ejemplo n.º 3
0
 /**
  * Compares this user to another to determine if they are the same.
  *
  * @param UserInterface $user The user
  * @return boolean True if equal, false othwerwise.
  */
 public function equals(Usuarios $user)
 {
     return md5($this->getUsername()) == md5($user->getUsername());
 }
Ejemplo n.º 4
0
 /**
  * 
  * @ParamConverter("owner", options={"mapping": {"owner_target" = "id"}})
  */
 public function commentsWallAction(UsuarioEntity $owner, $target)
 {
     $user = $this->getUser();
     return $this->render('juzzCommentsBundle:Default:comments-wall.html.twig', array('comments' => array(), 'policy' => $owner->getPoliticaComentarios(), 'target' => $target, 'user' => $user));
 }
Ejemplo n.º 5
0
 /**
  * Devuelve los últimos 5 followers para $user
  * @ParamConverter("user", options={"mapping": {"user" = "id"}})
  * @Cache(expires="tomorrow")
  */
 public function lastAction(UsuarioEntity $user)
 {
     return $this->render('juzzUsuariosBundle:Usuarios:public/partials/last_followers.html.twig', array('followers' => $user->getFollowers(), 'owner_nick' => $user->getNick()));
 }