예제 #1
0
 public function addViewerAction()
 {
     $authenticated = $this->get('security.context')->getToken()->getUser();
     $message = ' ';
     $request = $this->getRequest();
     $user = new Usuario();
     $user->setRole("ROLE_VIEWER");
     $user->setSalt("123");
     $user->setCentro($this->GetEntityByUser($authenticated));
     $form = $this->createForm(new UsuarioType());
     $form->handleRequest($request);
     if ($form->isValid()) {
         $newName = $form->getData()->getNombre();
         $newLast = $form->getData()->getApellidos();
         $newEmail = $form->getData()->getEmail();
         $newPass = $form->getData()->getPassword();
         //            $newRole = $form->getData()->getRole();
         $newUsername = $form->getData()->getUsername();
         //            $newSalt = $form->getData()->getSalt();
         //            $newEntity = $form->getData()->getCentro();
         $user->setNombre($newName);
         $user->setApellidos($newLast);
         $user->setEmail($newEmail);
         $user->setPassword($newPass);
         $user->setUsername($newUsername);
         $em = $this->getDoctrine()->getManager();
         $em->persist($user);
         $em->flush();
         $message = 'El usuario fue introducido satisfactoriamente';
         return $this->render('EditorBundle:Edit:index.html.twig', array('message' => $message));
     }
     return $this->render('EditorBundle:Edit:add.html.twig', array('user' => $user, 'form' => $form->createView(), 'message' => $message));
 }
예제 #2
0
 public function crearAction()
 {
     $peticion = $this->getRequest();
     $usuario = new Usuario();
     $formulario = $this->createForm(new UsuarioType());
     $formulario->handleRequest($peticion);
     if ($formulario->isValid()) {
         $_newNombre = $formulario->getData()->getNombre();
         $_newApellidos = $formulario->getData()->getApellidos();
         $_newEmail = $formulario->getData()->getEmail();
         $_newPass = $formulario->getData()->getPassword();
         $_newRole = $formulario->getData()->getRole();
         $_newUsername = $formulario->getData()->getUsername();
         $_newSalt = $formulario->getData()->getSalt();
         $_newCentro = $formulario->getData()->getCentro();
         /* $factory = $this->get('security.encoder_factory');
            $encoder = $factory->getEncoder($usuario);
            $password = $encoder->encodePassword($_newPass, $_newSalt);*/
         $usuario->setNombre($_newNombre);
         $usuario->setApellidos($_newApellidos);
         $usuario->setEmail($_newEmail);
         $usuario->setPassword($_newPass);
         //            $usuario->setPassword($password);
         $usuario->setRole($_newRole);
         $usuario->setUsername($_newUsername);
         $usuario->setSalt($_newSalt);
         $usuario->setCentro($_newCentro);
         $em = $this->getDoctrine()->getManager();
         $em->persist($usuario);
         $em->flush();
         //            var_dump($password);
         //            die;
         return $this->redirect($this->generateUrl('admin_usuario_index'));
     }
     return $this->render('AdminBundle:Usuario:crear.html.twig', array('usuario' => $usuario, 'form' => $formulario->createView()));
 }
 public function setNombre($nombre)
 {
     $this->__load();
     return parent::setNombre($nombre);
 }